code: def _can_cast(from_dtype, to_dtype):
      """
      Utility function to determine if we can cast
      from `from_dtype` to `to_dtype`. This function primarily calls
      `np.can_cast` but with some special handling around
      cudf specific dtypes.
      """
      if cudf.utils.utils.is_na_like(from_dtype):
          return True
      if isinstance(from_dtype, type):
          from_dtype = cudf.dtype(from_dtype)
      if isinstance(to_dtype, type):
          to_dtype = cudf.dtype(to_dtype)
  
      # TODO : Add precision & scale checking for
      # decimal types in future
  
      if isinstance(from_dtype, cudf.core.dtypes.DecimalDtype):
          if isinstance(to_dtype, cudf.core.dtypes.DecimalDtype):
              return True
          elif isinstance(to_dtype, np.dtype):
              if to_dtype.kind in {"i", "f", "u", "U", "O"}:
                  return True
              else:
                  return False
      elif isinstance(from_dtype, np.dtype):
          if isinstance(to_dtype, np.dtype):
              return np.can_cast(from_dtype, to_dtype)
          elif isinstance(to_dtype, cudf.core.dtypes.DecimalDtype):
              if from_dtype.kind in {"i", "f", "u", "U", "O"}:
                  return True
              else:
                  return False
          elif isinstance(to_dtype, cudf.core.types.CategoricalDtype):
              return True
          else:
              return False
      elif isinstance(from_dtype, cudf.core.dtypes.ListDtype):
          # TODO: Add level based checks too once casting of
          # list columns is supported
          if isinstance(to_dtype, cudf.core.dtypes.ListDtype):
              return np.can_cast(
                  from_dtype.leaf_type, to_dtype.leaf_type
              )
          else:
              return False
      elif isinstance(from_dtype, cudf.core.dtypes.CategoricalDtype):
          if isinstance(to_dtype, cudf.core.dtypes.CategoricalDtype):
              return True
          elif isinstance(to_dtype, np.dtype):
              return np.can_cast(from_dtype._categories.dtype, to_dtype)
          else:
              return False
      else:
          return np.can_cast(from_dtype, to_dtype)
  
imports: import datetime
  from collections import namedtuple
  from decimal import Decimal
  import cupy
  import numpy
  import pandas
  import pyarrow
  from pandas.core.dtypes.common import infer_dtype_from_object
  import cudf
  from cudf._typing import DtypeObj
  from cudf.api.types import is_bool, is_float, is_integer
label_desc: Use image node_id 22 for calling a global function with example usage: _can_cast(from_dtype, to_dtype) and returns: True, True, np, True, False, np, False, np, True, False, True, False, True, np, False