code: def resolve_engine(
      engine: Union[EngineAbstract, str],
      g_or_df: Optional[Any] = None,
  ) -> Engine:
      if isinstance(engine, str):
          engine = EngineAbstract(engine)
  
      # if an Engine (concrete), just use that
      if engine != EngineAbstract.AUTO:
          return Engine(engine.value)
  
      if g_or_df is not None:
          # work around circular dependency
          from graphistry.Plottable import Plottable
  
          if isinstance(g_or_df, Plottable):
              if (
                  g_or_df._nodes is not None
                  and g_or_df._edges is not None
              ):
                  if not isinstance(
                      g_or_df._nodes, type(g_or_df._edges)
                  ):
                      raise ValueError(
                          f"Edges and nodes must be same type for auto engine selection, got: {type(g_or_df._edges)} and {type(g_or_df._nodes)}"
                      )
              g_or_df = (
                  g_or_df._edges
                  if g_or_df._edges is not None
                  else g_or_df._nodes
              )
  
      if g_or_df is not None:
          if isinstance(g_or_df, pd.DataFrame):
              return Engine.PANDAS
  
          has_cudf_dependancy_, _, _ = lazy_cudf_import_has_dependancy()
          if has_cudf_dependancy_:
              import cudf
  
              if isinstance(g_or_df, cudf.DataFrame):
                  return Engine.CUDF
              raise ValueError(
                  f"Expected cudf dataframe, got: {type(g_or_df)}"
              )
  
      has_cudf_dependancy_, _, _ = lazy_cudf_import_has_dependancy()
      if has_cudf_dependancy_:
          return Engine.CUDF
      return Engine.PANDAS
  
file_path: pygraphistry/graphistry/Engine.py
imports: import pandas
  from typing import Any, Optional, Union
  from enum import Enum
label_desc: Use image node_id 2 for calling a global function with example usage: resolve_engine(engine, g_or_df) and returns: Engine, Engine, Engine, Engine, Engine