A helper function to convert from operator_name_and_kwargs to new object of type initializer_class. This function serves two purposes: 1. Support for custom initialization operators being passed in 2. Allow user to specify a custom Initializer without overwriting default ope
(initializer_class,
operator_name_and_kwargs,
default_operator_name_and_kwargs)
| 119 | ) |
| 120 | |
| 121 | def update_initializer(initializer_class, |
| 122 | operator_name_and_kwargs, |
| 123 | default_operator_name_and_kwargs): |
| 124 | ''' |
| 125 | A helper function to convert from operator_name_and_kwargs to new |
| 126 | object of type initializer_class. This function serves two purposes: |
| 127 | |
| 128 | 1. Support for custom initialization operators being passed in |
| 129 | 2. Allow user to specify a custom Initializer without overwriting |
| 130 | default operators used for initialization |
| 131 | |
| 132 | If initializer_class is None, creates a default initializer using |
| 133 | the Initializer class and operator_name_and_kwargs provided |
| 134 | |
| 135 | If operator_name_and_kwargs is None, uses default_operator_name_and_kwargs |
| 136 | |
| 137 | returns an instantiated Initializer object |
| 138 | ''' |
| 139 | def get_initializer_args(): |
| 140 | return ( |
| 141 | operator_name_and_kwargs or |
| 142 | default_operator_name_and_kwargs |
| 143 | ) |
| 144 | |
| 145 | if initializer_class is not None: |
| 146 | init = initializer_class(get_initializer_args()[0], |
| 147 | **get_initializer_args()[1]) |
| 148 | else: |
| 149 | init = Initializer( |
| 150 | get_initializer_args()[0], |
| 151 | **get_initializer_args()[1] |
| 152 | ) |
| 153 | return init |
nothing calls this directly
no test coverage detected
searching dependent graphs…