code: def broadcast_common_batch_shape(
      *args: Sequence[tf.Tensor],
      event_ranks: Optional[int] = None,
      name: Optional[str] = None,
  ) -> Tuple[tf.Tensor]:
      """Broadcasts argument batch shapes to the common shape.
  
      Each input `Tensor` is assumed to be of shape `batch_shape_i + event_shape_i`.
      The function finds a common `batch_shape` and broadcasts each `Tensor` to
      `batch_shape + event_shape_i`. The common batch shape is the minimal shape
      such that all `batch_shape_i` can broadcast to it.
  
      #### Example 1. Batch shape is all dimensions but the last one
      ```python
      import tensorflow as tf
      import tf_quant_finance as tff
  
      # Two Tensors of shapes [2, 3] and [2]. The batch shape of the 1st Tensor is
      # [2] and for the second is []. The common batch shape is [2]
      args = [tf.ones([2, 3], dtype=tf.float64), tf.constant([True, False])]
      tff.utils.broadcast_common_batch_shape(*args)
      # Expected: (array([[1., 1., 1.], [1., 1., 1.]]),
      #            array([[True, True], [False, False]])
      ```
  
      #### Example 2. Specify ranks of event shapes
      ```python
      import tensorflow as tf
      import tf_quant_finance as tff
  
      args = [tf.ones([2, 3], dtype=tf.float64), tf.constant([True, False])]
      tff.utils.broadcast_common_batch_shape(*args,
                                             event_ranks)
      # Expected: (array([[1., 1., 1.], [1., 1., 1.]]),
      #            array([[True, True], [False, False]])
      ```
  
      Args:
        *args: A sequence of `Tensor`s of compatible shapes and any `dtype`s.
        event_ranks: A sequence of integers of the same length as `args` specifying
          ranks of `event_shape` for each input `Tensor`.
          Default value: `None` which means that all dimensions but the last one
          are treated as batch dimension.
        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 tuple of broadcasted `Tensor`s. Each `Tensor` has the same `dtype` as the
        corresponding input `Tensor`.
  
      Raises:
        ValueError:
          (a) If `event_ranks` is supplied and is of different from `args` length.
          (b) If inputs are of incompatible shapes.
      """
      name = "broadcast_common_batch_shape" if name is None else name
      with tf.name_scope(name):
          if event_ranks is None:
              event_ranks = [1] * len(args)
          if len(event_ranks) != len(args):
              raise ValueError(
                  "`args` and `event_dims` should be of the same length but are {0} "
                  "and {1} elements, respectively".format(
                      len(event_ranks), len(args)
                  )
              )
          dummies = [
              tf.zeros(get_shape(arg)[:-d])
              for arg, d in zip(args, event_ranks)
          ]
          common_batch_shape = common_shape(*dummies)
          return tuple(
              tf.broadcast_to(
                  x,
                  tf.concat(
                      [common_batch_shape, get_shape(x)[-d:]], axis=0
                  ),
              )
              for x, d in zip(args, event_ranks)
          )
  
imports: from typing import Tuple, Sequence, Union, Optional
  import tensorflow.compat.v2
  from tf_quant_finance import types
label_desc: Use image node_id 4 for calling a global function with example usage: broadcast_common_batch_shape() and returns: tuple