def _load_model(model_path, keras_module, **kwargs):
    keras_models = importlib.import_module((keras_module.__name__ + '.models'))
    custom_objects = kwargs.pop('custom_objects', {})
    custom_objects_path = None
    if os.path.isdir(model_path):
        if os.path.isfile(os.path.join(model_path, _CUSTOM_OBJECTS_SAVE_PATH)):
            custom_objects_path = os.path.join(model_path, _CUSTOM_OBJECTS_SAVE_PATH)
        model_path = os.path.join(model_path, _MODEL_SAVE_PATH)
    if (custom_objects_path is not None):
        import cloudpickle
        with open(custom_objects_path, 'rb') as in_f:
            pickled_custom_objects = cloudpickle.load(in_f)
            pickled_custom_objects.update(custom_objects)
            custom_objects = pickled_custom_objects
    from distutils.version import StrictVersion
    if (StrictVersion(keras_module.__version__.split('-')[0]) >= StrictVersion('2.2.3')):
        import h5py
        with h5py.File(os.path.abspath(model_path), 'r') as model_path:
            return keras_models.load_model(model_path, custom_objects=custom_objects, **kwargs)
    else:
        return keras_models.load_model(model_path, custom_objects=custom_objects, **kwargs)
def _load_model(model_path, keras_module, **kwargs):
    keras_models = importlib.import_module((keras_module.__name__ + '.models'))
    custom_objects = kwargs.pop('custom_objects', {})
    custom_objects_path = None
    if os.path.isdir(model_path):
        if os.path.isfile(os.path.join(model_path, _CUSTOM_OBJECTS_SAVE_PATH)):
            custom_objects_path = os.path.join(model_path, _CUSTOM_OBJECTS_SAVE_PATH)
        model_path = os.path.join(model_path, _MODEL_SAVE_PATH)
    if (custom_objects_path is not None):
        import cloudpickle
        with open(custom_objects_path, 'rb') as in_f:
            pickled_custom_objects = cloudpickle.load(in_f)
            pickled_custom_objects.update(custom_objects)
            custom_objects = pickled_custom_objects
    from distutils.version import StrictVersion
    if (StrictVersion(keras_module.__version__.split('-')[0]) >= StrictVersion('2.2.3')):
        import h5py
        with h5py.File(os.path.abspath(model_path), 'r') as model_path:
            return keras_models.load_model(model_path, custom_objects=custom_objects, **kwargs)
    else:
        return keras_models.load_model(model_path, custom_objects=custom_objects, **kwargs)