code: def cast_like(x, y):
      """Cast x to y's dtype, if necessary."""
      x = tf.convert_to_tensor(value=x)
      y = tf.convert_to_tensor(value=y)
  
      if x.dtype.base_dtype == y.dtype.base_dtype:
          return x
  
      cast_x = tf.cast(x, y.dtype)
      if cast_x.device != x.device:
          x_name = "(eager Tensor)"
          try:
              x_name = x.name
          except AttributeError:
              pass
          tf.compat.v1.logging.warning(
              "Cast for %s may induce copy from '%s' to '%s'",
              x_name,
              x.device,
              cast_x.device,
          )
      return cast_x
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  import tensorflow_addons
label_desc: Use image node_id 1 for calling a global function with example usage: cast_like(x, y) and returns: cast_x, x