code: def _generate_backend_config() -> _BackendConfig:
      def _generate_by_name(
          name: _typing.Optional[str] = ...,
      ) -> _BackendConfig:
          if name in (None, Ellipsis, ...) or not isinstance(name, str):
              try:
                  import dgl
  
                  return _DGLConfig()
              except ModuleNotFoundError:
                  pass
              try:
                  import torch_geometric
  
                  return _PyGConfig()
              except ModuleNotFoundError:
                  raise ModuleNotFoundError(
                      "Neither DGL nor PyTorch-Geometric exists"
                  )
          elif name.lower() not in ("dgl", "pyg"):
              __warning_message = " ".join(
                  (
                      "The environment variable AUTOGL_BACKEND specified",
                      'but is neither "dgl" nor "pyg",',
                      "thus the environment variable is ignored",
                      "and dependent backend for AutoGL is set automatically",
                  )
              )
              _backend_logger.warning(__warning_message)
              return _generate_by_name()
          elif name.lower() == "dgl":
              try:
                  import dgl
  
                  return _DGLConfig()
              except ModuleNotFoundError:
                  pass
              try:
                  import torch_geometric
  
                  __warning_message: str = " ".join(
                      (
                          "The required backend DGL is not installed,",
                          "use PyTorch-Geometric instead.",
                      )
                  )
                  _backend_logger.warning(__warning_message)
                  return _PyGConfig()
              except ModuleNotFoundError:
                  raise ModuleNotFoundError(
                      "Neither DGL nor PyTorch-Geometric exists"
                  )
          elif name.lower() == "pyg":
              try:
                  import torch_geometric
  
                  return _PyGConfig()
              except ModuleNotFoundError:
                  pass
              try:
                  import dgl
  
                  __warning_message: str = " ".join(
                      (
                          "The required backend PyTorch-Geometric is not installed,",
                          "use DGL instead.",
                      )
                  )
                  _backend_logger.warning(__warning_message)
                  return _DGLConfig()
              except ModuleNotFoundError:
                  raise ModuleNotFoundError(
                      "Neither DGL nor PyTorch-Geometric exists"
                  )
          else:
              return _generate_by_name()
  
      if "AUTOGL_BACKEND" in os.environ:
          return _generate_by_name(os.getenv("AUTOGL_BACKEND"))
      else:
          return _generate_by_name()
  
imports: import os
  import logging
  import typing
label_desc: Use image node_id 1 for calling a global function with example usage: _generate_backend_config() and returns: _generate_by_name, _generate_by_name, _DGLConfig, _PyGConfig, _generate_by_name, _DGLConfig, _PyGConfig, _generate_by_name, _PyGConfig, _DGLConfig