code: def get_shape(
      x: tf.Tensor, name: Optional[str] = None
  ) -> Union[tf.TensorShape, types.IntTensor]:
      """Returns static shape of `x` if it is fully defined, or dynamic, otherwise.
  
      ####Example
      ```python
      import tensorflow as tf
      import tf_quant_finance as tff
  
      x = tf.zeros([5, 2])
      prefer_static_shape(x)
      # Expected: [5, 2]
  
      Args:
        x: A tensor of any shape and `dtype`
        name: Python string. The name to give to the ops created by this function.
          Default value: `None` which maps to the default name
          `get_shape`.
  
      Returns:
        A shape of `x` which a list, if the shape is fully defined, or a `Tensor`
        for dynamically shaped `x`.
      """
      name = "get_shape" if name is None else name
      with tf.name_scope(name):
          x = tf.convert_to_tensor(x)
          is_fully_defined = x.shape.is_fully_defined()
          if is_fully_defined:
              return x.shape
          return tf.shape(x)
  
imports: from typing import Tuple, Sequence, Union, Optional
  import tensorflow.compat.v2
  from tf_quant_finance import types
label_desc: Use image node_id 1 for calling a global function with example usage: get_shape(x, name) and returns: tf, x