          _TF_VERS = float(".".join(tf.__version__.split(".")[:2]))  # pylint:disable=no-member
      return _TF_VERS
  
  
  def get_keras_custom_objects():
      """ Wrapper to obtain keras.utils.get_custom_objects from correct location depending on
      backend used and tensorflow version. """
      # pylint:disable=no-name-in-module,import-outside-toplevel
      if get_backend() == "amd" or get_tf_version() < 2.8:
          from keras.utils import get_custom_objects
      else:
          from keras.utils.generic_utils import get_custom_objects
      return get_custom_objects()
  
  
  def get_folder(path, make_folder=True):
      """ Return a path to a folder, creating it if it doesn't exist
  
      Parameters
      ----------
 
</s> remove 

class KerasFinder(importlib.abc.MetaPathFinder):
    """ Importlib Abstract Base Class for intercepting the import of Keras and returning either
    Keras (AMD backend) or tensorflow.keras (any other backend).

    The Importlib documentation is sparse at best, and real world examples are pretty much
    non-existent. Coupled with this, the import ``tensorflow.keras`` does not resolve so we need
    to split out to the actual location of Keras within ``tensorflow_core``. This method works, but
    it relies on hard coded paths, and is likely to not be the most robust.

    A custom loader is not used, as we can use the standard loader once we have returned the
    correct spec.
    """
    def __init__(self):
        self._logger = logging.getLogger(__name__)
        self._backend = get_backend()
        self._tf_keras_locations = [["tensorflow_core", "python", "keras", "api", "_v2"],
                                    ["tensorflow", "python", "keras", "api", "_v2"]]

    def find_spec(self, fullname, path, target=None):  # pylint:disable=unused-argument
        """ Obtain the spec for either keras or tensorflow.keras depending on the backend in use.

        If keras is not passed in as part of the :attr:`fullname` or the path is not ``None``
        (i.e this is a dependency import) then this returns ``None`` to use the standard import
        library.

        Parameters
        ----------
        fullname: str
            The absolute name of the module to be imported
        path: str
            The search path for the module
        target: module object, optional
            Inherited from parent but unused

        Returns
        -------
        :class:`importlib.ModuleSpec`
            The spec for the Keras module to be imported
        """
        prefix = fullname.split(".")[0]
        suffix = fullname.split(".")[-1]
        if prefix != "keras" or path is not None:
            return None
        self._logger.debug("Importing '%s' as keras for backend: '%s'",
                           "keras" if self._backend == "amd" else "tf.keras", self._backend)
        path = sys.path if path is None else path
        for entry in path:
            locations = ([os.path.join(entry, *location)
                          for location in self._tf_keras_locations]
                         if self._backend != "amd" else [entry])
            for location in locations:
                self._logger.debug("Scanning: '%s' for '%s'", location, suffix)
                if os.path.isdir(os.path.join(location, suffix)):
                    filename = os.path.join(location, suffix, "__init__.py")
                    submodule_locations = [os.path.join(location, suffix)]
                else:
                    filename = os.path.join(location, suffix + ".py")
                    submodule_locations = None
                if not os.path.exists(filename):
                    continue
                retval = importlib.util.spec_from_file_location(
                    fullname,
                    filename,
                    submodule_search_locations=submodule_locations)
                self._logger.debug("Found spec: %s", retval)
                return retval
        self._logger.debug("Spec not found for '%s'. Falling back to default import", fullname)
        return None
 </s> add  </s> remove from lib.utils import get_backend, get_keras_custom_objects as get_custom_objects
 </s> add from lib.utils import get_backend

if get_backend() == "amd":
    from keras.utils import get_custom_objects  # pylint:disable=no-name-in-module
    from keras import backend as K
    from keras import initializers
else:
    # Ignore linting errors from Tensorflow's thoroughly broken import system
    from tensorflow.keras.utils import get_custom_objects  # noqa pylint:disable=no-name-in-module,import-error
    from tensorflow.keras import initializers, backend as K  # noqa pylint:disable=no-name-in-module,import-error </s> remove     from keras.utils import conv_utils  # pylint:disable=ungrouped-imports
 </s> add     from keras.utils import get_custom_objects, conv_utils  # pylint:disable=no-name-in-module
    import keras.backend as K
    from keras.layers import InputSpec, Layer </s> remove     from keras.backend \
        import normalize_data_format  # pylint:disable=ungrouped-imports,no-name-in-module
 </s> add     from keras.utils import get_custom_objects  # pylint:disable=no-name-in-module
    from keras.layers import Layer, InputSpec
    from keras import initializers, regularizers, constraints, backend as K
    from keras.backend import normalize_data_format  # pylint:disable=no-name-in-module </s> remove from keras.layers import InputSpec, Layer

from lib.utils import get_backend, get_keras_custom_objects as get_custom_objects
 </s> add from lib.utils import get_backend
          _TF_VERS = float(".".join(tf.__version__.split(".")[:2]))  # pylint:disable=no-member
      return _TF_VERS
  
  











  def get_folder(path, make_folder=True):
      """ Return a path to a folder, creating it if it doesn't exist
  
      Parameters
      ----------
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Update all Keras Imports to be conditional (#1214)

* Remove custom keras importer

* first round keras imports fix

* launcher.py: Remove KerasFinder references

* 2nd round keras imports update (lib and extract)

* 3rd round keras imports update (train)

* remove KerasFinder from tests

* 4th round keras imports update (tests) 
lib/utils.py