code: def maybe_get_static_value(x, dtype=None):
      """Helper which tries to return a static value.
  
      Given `x`, extract it's value statically, optionally casting to a specific
      dtype. If this is not possible, None is returned.
  
      Args:
        x: `Tensor` for which to extract a value statically.
        dtype: Optional dtype to cast to.
  
      Returns:
        Statically inferred value if possible, otherwise None.
      """
      if x is None:
          return x
      try:
          # This returns an np.ndarray.
          x_ = tf.get_static_value(x)
      except TypeError:
          x_ = x
      if x_ is None or dtype is None:
          return x_
      return np.array(x_, dtype)
  
imports: import functools
  import hashlib
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 20 for calling a global function with example usage: maybe_get_static_value(x, dtype) and returns: np, x, x_