code: def trace(name=None):
      """Returns a function which prints info related to input."""
      name = "" if name is None else "name:{:10}  ".format(name)
  
      def trace_(x):
          """Prints input shape and dtype if possible, else value."""
          if hasattr(x, "dtype") and hasattr(x, "shape"):
              print(
                  "--- TRACE:  {}shape:{:16}  dtype:{:10}".format(
                      name,
                      str(tensorshape_util.as_list(x.shape)),
                      dtype_util.name(x.dtype),
                  )
              )
          else:
              print("--- TRACE:  {}value:{}".format(name, x))
          sys.stdout.flush()
          return x
  
      return trace_
  
imports: import collections
  import contextlib
  import functools
  import sys
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 8 for calling a global function with example usage: trace(name) and returns: trace_, x