code: def common_shape(
      *args: Sequence[tf.Tensor], name: Optional[str] = None
  ) -> Union[tf.TensorShape, tf.Tensor]:
      """Returns common shape for a sequence of Tensors.
  
      The common shape is the smallest-rank shape to which all tensors are
      broadcastable.
  
      #### Example
      ```python
      import tensorflow as tf
      import tf_quant_finance as tff
  
      args = [tf.ones([1, 2], dtype=tf.float64), tf.constant([[True], [False]])]
      tff.utils.common_shape(*args)
      # Expected: [2, 2]
      ```
  
      Args:
        *args: A sequence of `Tensor`s of compatible shapes and any `dtype`s.
        name: Python string. The name to give to the ops created by this function.
          Default value: `None` which maps to the default name
          `broadcast_tensor_shapes`.
  
      Returns:
        A common shape for the input `Tensor`s, which an instance of TensorShape,
        if the input shapes are fully defined, or a `Tensor` for dynamically shaped
        inputs.
  
      Raises:
        ValueError: If inputs are of incompatible shapes.
      """
      name = "common_shape" if name is None else name
      with tf.name_scope(name):
          # Flag to decide whether input Tensors have fully defined shapes
          is_fully_defined = True
          if args:
              for arg in args:
                  arg = tf.convert_to_tensor(arg)
                  is_fully_defined &= arg.shape.is_fully_defined()
              if is_fully_defined:
                  output_shape = args[0].shape
                  for arg in args[1:]:
                      try:
                          output_shape = tf.broadcast_static_shape(
                              output_shape, arg.shape
                          )
                      except ValueError:
                          raise ValueError(
                              f"Shapes of {args} are incompatible"
                          )
                  return output_shape
              output_shape = tf.shape(args[0])
              for arg in args[1:]:
                  output_shape = tf.broadcast_dynamic_shape(
                      output_shape, tf.shape(arg)
                  )
              return output_shape
  
imports: from typing import Tuple, Sequence, Union, Optional
  import tensorflow.compat.v2
  from tf_quant_finance import types
label_desc: Use image node_id 2 for calling a global function with example usage: common_shape() and returns: output_shape, output_shape