code: def import_optional(mod, default_mod_class=MissingModule):
      """
      import the "optional" module 'mod' and return the module object or object.
      If the import raises ModuleNotFoundError, returns an instance of
      default_mod_class.
  
      This method was written to support importing "optional" dependencies so
      code can be written to run even if the dependency is not installed.
  
      Example
      -------
      >> from cugraph.utils import import_optional
      >> nx = import_optional("networkx")  # networkx is not installed
      >> G = nx.Graph()
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        ...
      RuntimeError: This feature requires the networkx package/module
  
      Example
      -------
      >> class CuDFFallback:
      ..   def __init__(self, mod_name):
      ..     assert mod_name == "cudf"
      ..     warnings.warn("cudf could not be imported, using pandas instead!")
      ..   def __getattr__(self, attr):
      ..     import pandas
      ..     return getattr(pandas, attr)
      ...
      >> from cugraph.utils import import_optional
      >> df_mod = import_optional("cudf", default_mod_class=CuDFFallback)
      <stdin>:4: UserWarning: cudf could not be imported, using pandas instead!
      >> df = df_mod.DataFrame()
      >> df
      Empty DataFrame
      Columns: []
      Index: []
      >> type(df)
      <class 'pandas.core.frame.DataFrame'>
      >>
      """
      try:
          return importlib.import_module(mod)
      except ModuleNotFoundError:
          return default_mod_class(mod_name=mod)
  
file_path: cugraph/python/cugraph-service/client/cugraph_service_client/remote_graph_utils.py
imports: import importlib
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: import_optional(mod, default_mod_class) and returns: importlib, default_mod_class