code: def _expand_to_beam_size(tensor, beam_size):
      """Tiles a given tensor by beam_size.
  
      Args:
          tensor: tensor to tile [batch_size, ...]
          beam_size: How much to tile the tensor by.
  
      Returns:
          Tiled tensor [batch_size, beam_size, ...]
      """
      if not isinstance(tensor, tf.Tensor):
          return tensor
      tensor = tf.expand_dims(tensor, axis=1)
      tile_dims = [1] * tensor.shape.ndims
      tile_dims[1] = beam_size
  
      return tf.tile(tensor, tile_dims)
  
file_path: texar/texar/tf/utils/beam_search.py
imports: import tensorflow
  from tensorflow.python.util import nest
  from texar.tf.utils.shapes import shape_list
label_desc: Use image node_id 3 for calling a global function with example usage: _expand_to_beam_size(tensor, beam_size) and returns: tf, tensor