code: def _prepare_boundary_conditions(
      boundary_tensor, value_grid, batch_rank, dim
  ):
      """Prepares values received from boundary_condition callables."""
      if boundary_tensor is None:
          return None
      boundary_tensor = tf.convert_to_tensor(
          boundary_tensor, value_grid.dtype
      )
      # Broadcast to the shape of the boundary: it is the shape of value grid with
      # one dimension removed.
      dim_to_remove = batch_rank + dim
      broadcast_shape = []
      # Shape slicing+concatenation seems error-prone, so let's do it simply.
      for i, size in enumerate(value_grid.shape):
          if i != dim_to_remove:
              broadcast_shape.append(size)
      return tf.broadcast_to(boundary_tensor, broadcast_shape)
  
imports: import tensorflow.compat.v2
  from tf_quant_finance import utils
label_desc: Use image node_id 16 for calling a global function with example usage: _prepare_boundary_conditions(boundary_tensor, value_grid, batch_rank, dim) and returns: tf, None