code: def _broadcast_parameter_with_batch_shape(
      param, param_ndims_to_matrix_ndims, batch_shape
  ):
      """Broadcasts `param` with the given batch shape, recursively."""
      if hasattr(param, "batch_shape_tensor"):
          # Recursively broadcast every parameter inside the operator.
          override_dict = {}
          for (
              name,
              ndims,
          ) in (
              param._experimental_parameter_ndims_to_matrix_ndims.items()
          ):  # pylint:disable=protected-access,line-too-long
              sub_param = getattr(param, name)
              override_dict[name] = nest.map_structure_up_to(
                  sub_param,
                  functools.partial(
                      _broadcast_parameter_with_batch_shape,
                      batch_shape=batch_shape,
                  ),
                  sub_param,
                  ndims,
              )
          parameters = dict(param.parameters, **override_dict)
          return type(param)(**parameters)
  
      base_shape = prefer_static.concat(
          [
              batch_shape,
              array_ops.ones(
                  [param_ndims_to_matrix_ndims], dtype=dtypes.int32
              ),
          ],
          axis=0,
      )
      return _ops.broadcast_to(
          param,
          _ops.broadcast_dynamic_shape(
              base_shape, prefer_static.shape(param)
          ),
      )
  
file_path: probability/tensorflow_probability/python/internal/backend/numpy/gen/slicing.py
imports: import collections
  import functools
  import numpy
  from tensorflow_probability.python.internal.backend.numpy import dtype
  from tensorflow_probability.python.internal.backend.numpy import ops
  from tensorflow_probability.python.internal.backend.numpy import numpy_array
  from tensorflow_probability.python.internal.backend.numpy import nest
  import numpy
  from tensorflow_probability.python.internal.backend.numpy import linalg_impl
  from tensorflow_probability.python.internal.backend.numpy import ops
  from tensorflow_probability.python.internal.backend.numpy.gen import tensor_shape
  from tensorflow_probability.python.internal.backend.numpy import private
label_desc: Use image node_id 2 for calling a global function with example usage: _broadcast_parameter_with_batch_shape(param, param_ndims_to_matrix_ndims, batch_shape) and returns: _ops, type