code: def _broadcast_batch_shape(x, batch_shape, dim):
      # `x` is of shape `batch_shape + [d1,.., dn, dim]`, where n == dim
      x_shape_no_batch = _get_static_shape(x)[-dim - 1 :]
      if isinstance(x_shape_no_batch, list) and isinstance(
          batch_shape, list
      ):
          return tf.broadcast_to(x, batch_shape + x_shape_no_batch)
      else:
          output_shape = tf.concat(
              [batch_shape, x_shape_no_batch], axis=0
          )
          return tf.broadcast_to(x, output_shape)
  
file_path: tf-quant-finance/tf_quant_finance/models/generic_ito_process.py
imports: import tensorflow.compat.v2
  from tf_quant_finance.math.pde import fd_solvers
  from tf_quant_finance.models import euler_sampling
  from tf_quant_finance.models import ito_process
label_desc: Use image node_id 4 for calling a global function with example usage: _broadcast_batch_shape(x, batch_shape, dim) and returns: tf, tf