                  os.environ["KERAS_BACKEND"] = "tensorflow"
              set_backend("cpu")
              logger.info(msg)
  
          # Add Keras finder to the meta_path list as the first item
          sys.meta_path.insert(0, KerasFinder())
  
          logger.debug("Executing: %s. PID: %s", self._command, os.getpid())
  
          if get_backend() == "amd":
              plaidml_found = self._setup_amd(arguments)
              if not plaidml_found:
 
</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         self._model_kwargs = dict() if not model_kwargs else model_kwargs
 </s> add         self._model_kwargs = {} if not model_kwargs else model_kwargs </s> remove         Add the Keras import interception code.

 </s> add  </s> remove         self._name = _get_name("upscale_ri_{}".format(filters))
 </s> add         self._name = _get_name(f"upscale_ri_{filters}") </s> remove             valid = [x for x in _MODEL_MAPPING if not _MODEL_MAPPING[x].get('no_amd')]
 </s> add             valid = [k for k, v in _MODEL_MAPPING.items() if not v.get('no_amd')]
                  os.environ["KERAS_BACKEND"] = "tensorflow"
              set_backend("cpu")
              logger.info(msg)
  



          logger.debug("Executing: %s. PID: %s", self._command, os.getpid())
  
          if get_backend() == "amd":
              plaidml_found = self._setup_amd(arguments)
              if not plaidml_found:
keep keep keep keep 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/cli/launcher.py