def load_tf_keras_optimizer(h5py_file, custom_objects=None):
    if (not custom_objects):
        custom_objects = {}

    def convert_custom_objects(obj):
        'Handles custom object lookup.\n\n        Arguments:\n            obj: object, dict, or list.\n\n        Returns:\n            The same structure, where occurrences\n                of a custom object name have been replaced\n                with the custom object.\n        '
        if isinstance(obj, list):
            deserialized = []
            for value in obj:
                deserialized.append(convert_custom_objects(value))
            return deserialized
        if isinstance(obj, dict):
            deserialized = {}
            for (key, value) in obj.items():
                deserialized[key] = convert_custom_objects(value)
            return deserialized
        if (obj in custom_objects):
            return custom_objects[obj]
        return obj
    (optimizer, optimizer_weight_values) = (None, None)
    training_config = h5py_file.attrs.get('training_config')
    training_config = json.loads(training_config.decode('utf-8'))
    optimizer_config = training_config['optimizer_config']
    optimizer = optimizers.deserialize(optimizer_config, custom_objects=custom_objects)
    if ('optimizer_weights' in h5py_file):
        optimizer_weights_group = h5py_file['optimizer_weights']
        optimizer_weight_names = [n.decode('utf8') for n in optimizer_weights_group.attrs['weight_names']]
        optimizer_weight_values = [optimizer_weights_group[n].value for n in optimizer_weight_names]
    if optimizer_weight_values:
        optimizer.set_weights(optimizer_weight_values)
    return optimizer
def load_tf_keras_optimizer(h5py_file, custom_objects=None):
    if (not custom_objects):
        custom_objects = {}

    def convert_custom_objects(obj):
        'Handles custom object lookup.\n\n        Arguments:\n            obj: object, dict, or list.\n\n        Returns:\n            The same structure, where occurrences\n                of a custom object name have been replaced\n                with the custom object.\n        '
        if isinstance(obj, list):
            deserialized = []
            for value in obj:
                deserialized.append(convert_custom_objects(value))
            return deserialized
        if isinstance(obj, dict):
            deserialized = {}
            for (key, value) in obj.items():
                deserialized[key] = convert_custom_objects(value)
            return deserialized
        if (obj in custom_objects):
            return custom_objects[obj]
        return obj
    (optimizer, optimizer_weight_values) = (None, None)
    training_config = h5py_file.attrs.get('training_config')
    training_config = json.loads(training_config.decode('utf-8'))
    optimizer_config = training_config['optimizer_config']
    optimizer = optimizers.deserialize(optimizer_config, custom_objects=custom_objects)
    if ('optimizer_weights' in h5py_file):
        optimizer_weights_group = h5py_file['optimizer_weights']
        optimizer_weight_names = [n.decode('utf8') for n in optimizer_weights_group.attrs['weight_names']]
        optimizer_weight_values = [optimizer_weights_group[n].value for n in optimizer_weight_names]
    if optimizer_weight_values:
        optimizer.set_weights(optimizer_weight_values)
    return optimizer