code: def make_safe_gpu_dataframes(X, y, engine):
      """helper method to coerce a dataframe to the correct type (pd vs cudf)"""
  
      def safe_cudf(X, y):
          new_kwargs = {}
          kwargs = {"X": X, "y": y}
          for key, value in kwargs.items():
              if isinstance(value, cudf.DataFrame) and engine in [
                  "pandas",
                  "sklearn",
                  "umap_learn",
              ]:
                  new_kwargs[key] = value.to_pandas()
              elif isinstance(value, pd.DataFrame) and engine == "cuml":
                  new_kwargs[key] = cudf.from_pandas(value)
              else:
                  new_kwargs[key] = value
          return new_kwargs["X"], new_kwargs["y"]
  
      has_cudf_dependancy_, _, cudf = lazy_cudf_import_has_dependancy()
      if has_cudf_dependancy_:
          # print('DBSCAN CUML Matrices')
          return safe_cudf(X, y)
      else:
          return X, y
  
imports: import logging
  import pandas
  import numpy
  from typing import Any, List, Union, TYPE_CHECKING, Tuple, Optional
  from typing_extensions import Literal
  from collections import Counter
  from graphistry.Plottable import Plottable
  from graphistry.constants import CUML, UMAP_LEARN, DBSCAN
  from graphistry.features import ModelDict
  from graphistry.feature_utils import get_matrix_by_column_parts
label_desc: Use image node_id 4 for calling a global function with example usage: make_safe_gpu_dataframes(X, y, engine) and returns: new_kwargs,  new_kwargs, safe_cudf, X,  y