code: def can_cast(from_: Union[Dtype, Array], to: Dtype, /) -> bool:
      """
      Array API compatible wrapper for :py:func:`np.can_cast <numpy.can_cast>`.
  
      See its docstring for more information.
      """
      if isinstance(from_, Array):
          from_ = from_.dtype
      elif from_ not in _all_dtypes:
          raise TypeError(
              f"{from_=}, but should be an array_api array or dtype"
          )
      if to not in _all_dtypes:
          raise TypeError(f"{to=}, but should be a dtype")
      # Note: We avoid np.can_cast() as it has discrepancies with the array API,
      # since NumPy allows cross-kind casting (e.g., NumPy allows bool -> int8).
      # See https://github.com/numpy/numpy/issues/20870
      try:
          # We promote `from_` and `to` together. We then check if the promoted
          # dtype is `to`, which indicates if `from_` can (up)cast to `to`.
          dtype = _result_type(from_, to)
          return to == dtype
      except TypeError:
          # _result_type() raises if the dtypes don't promote together
          return False
  
file_path: cupy/cupy/array_api/_data_type_functions.py
imports: from __future__ import annotations
  from ._array_object import Array
  from ._dtypes import _all_dtypes, _result_type
  from dataclasses import dataclass
  from typing import TYPE_CHECKING, List, Tuple, Union
  import cupy
label_desc: Use image node_id 4 for calling a global function with example usage: can_cast() and returns: unknown, False