code: def safe_to_cast(
      input_dtype_or_value: Any, output_dtype_or_value: Any
  ) -> bool:
      """Check if a dtype/value is safe to cast to another dtype/value
  
      Args:
        input_dtype_or_value: a dtype or value (to be passed to result_type)
          representing the source dtype.
        output_dtype_or_value: a dtype or value (to be passed to result_type)
          representing the target dtype.
  
      Returns:
        boolean representing whether the values are safe to cast according to
        default type promotion semantics.
  
      Raises:
        TypePromotionError: if the inputs have differing types and no type promotion
        path under the current jax_numpy_dtype_promotion setting.
  
      Examples:
  
        >>> safe_to_cast('int32', 'float64')
        True
        >>> safe_to_cast('float64', 'int32')
        False
        >>> safe_to_cast('float32', 'complex64')
        True
        >>> safe_to_cast('complex64', 'float64')
        False
      """
      input_dtype = dtype(input_dtype_or_value, canonicalize=True)
      output_dtype = dtype(output_dtype_or_value, canonicalize=True)
      if input_dtype == output_dtype:
          return True
      # We deliberately use output_dtype rather than output_dtype_or_value here:
      # this effectively treats the output dtype as always strongly-typed.
      return (
          result_type(input_dtype_or_value, output_dtype)
          == output_dtype
      )
  
imports: from __future__ import annotations
  import abc
  import builtins
  import functools
  from typing import cast, overload, Any, Literal, Union
  import warnings
  import ml_dtypes
  import numpy
  from jax._src import config
  from jax._src.typing import DType, DTypeLike
  from jax._src.util import set_module
  from jax._src import traceback_util
label_desc: Use image node_id 30 for calling a global function with example usage: safe_to_cast(input_dtype_or_value, output_dtype_or_value) and returns: unknown, True