code: def broadcast_parameter_with_batch_shape(
      param, param_event_ndims, batch_shape
  ):
      """Broadcasts `param` with the given batch shape, recursively."""
      if hasattr(param, "forward_min_event_ndims"):
          # Bijector-valued params are responsible for handling any structure in
          # their event ndims.
          return param._broadcast_parameters_with_batch_shape(  # pylint: disable=protected-access
              batch_shape, x_event_ndims=param_event_ndims
          )
  
      # Otherwise, param_event_ndims is a single integer, corresponding to the
      # number of batch dimensions of the parameter that were
      # treated as event dimensions by the outer context.
      base_shape = ps.concat(
          [batch_shape, ps.ones([param_event_ndims], dtype=np.int32)],
          axis=0,
      )
      if hasattr(param, "_broadcast_parameters_with_batch_shape"):
          return param._broadcast_parameters_with_batch_shape(
              base_shape
          )  # pylint: disable=protected-access
      elif hasattr(param, "matmul"):
          # TODO(davmre): support broadcasting LinearOperator parameters.
          return param
      return tf.broadcast_to(
          param, ps.broadcast_shape(base_shape, ps.shape(param))
      )
  
file_path: probability/tensorflow_probability/python/internal/batch_shape_lib.py
imports: import functools
  from absl import logging
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 9 for calling a global function with example usage: broadcast_parameter_with_batch_shape(param, param_event_ndims, batch_shape) and returns: tf, param, param, param