code: def _maybe_cast_element(x, dtype):
      if (
          isinstance(x, (tf.Tensor, tf.Variable))
          and x.dtype.is_floating
      ):
          x = tf.cast(x, dtype)
      return x
  
file_path: sonnet/sonnet/src/mixed_precision.py
imports: import uuid
  import contextlib
  from sonnet.src import custom_getter
  from sonnet.src import utils
  import tensorflow
  import tree
label_desc: Use image node_id 4 for calling a global function with example usage: _maybe_cast_element(x, dtype) and returns: x