parameters: (x, beam_size)
return_statement: return x
docstring: r"""
          Tile the batch dimension of a tensor. Specifically, this function takes
          a tensor t shaped `[batch_size, s0, s1, ...]` composed of minibatch 
          entries `t[0], ..., t[batch_size - 1]` and tiles it to have a shape
          `[batch_size * beam_size, s0, s1, ...]` composed of minibatch entries
          `t[0], t[0], ..., t[1], t[1], ...` where each minibatch entry is repeated
          `beam_size` times.
  
          Parameters:
              x(Variable): A tensor with shape `[batch_size, ...]`. The data type
                  should be float32, float64, int32, int64 or bool.
              beam_size(int): The beam width used in beam search.
  
          Returns:
              Variable: A tensor with shape `[batch_size * beam_size, ...]`, whose \
                  data type is same as `x`.
docstring_summary: r"""
          Tile the batch dimension of a tensor. Specifically, this function takes
          a tensor t shaped `[batch_size, s0, s1, ...]` composed of minibatch 
          entries `t[0], ..., t[batch_size - 1]` and tiles it to have a shape
          `[batch_size * beam_size, s0, s1, ...]` composed of minibatch entries
          `t[0], t[0], ..., t[1], t[1], ...` where each minibatch entry is repeated
          `beam_size` times.
docstring_tokens: r Tile the batch dimension of a tensor . Specifically this function takes a tensor t shaped [ batch_size s0 s1 ... ] composed of minibatch entries t [ 0 ] ... t [ batch_size - 1 ] and tiles it to have a shape [ batch_size * beam_size s0 s1 ... ] composed of minibatch entries t [ 0 ] t [ 0 ] ... t [ 1 ] t [ 1 ] ... where each minibatch entry is repeated beam_size times .
function: def tile_beam_merge_with_batch(x, beam_size):
          r"""
          Tile the batch dimension of a tensor. Specifically, this function takes
          a tensor t shaped `[batch_size, s0, s1, ...]` composed of minibatch 
          entries `t[0], ..., t[batch_size - 1]` and tiles it to have a shape
          `[batch_size * beam_size, s0, s1, ...]` composed of minibatch entries
          `t[0], t[0], ..., t[1], t[1], ...` where each minibatch entry is repeated
          `beam_size` times.
  
          Parameters:
              x(Variable): A tensor with shape `[batch_size, ...]`. The data type
                  should be float32, float64, int32, int64 or bool.
              beam_size(int): The beam width used in beam search.
  
          Returns:
              Variable: A tensor with shape `[batch_size * beam_size, ...]`, whose \
                  data type is same as `x`.
          """
          check_type(x, 'x', (Variable),
                     'BeamSearchDecoder.tile_beam_merge_with_batch')
          x = nn.unsqueeze(x, [1])  # [batch_size, 1, ...]
          expand_times = [1] * len(x.shape)
          expand_times[1] = beam_size
          x = paddle.tile(x, expand_times)  # [batch_size, beam_size, ...]
          x = nn.transpose(x, list(range(2, len(x.shape))) +
                           [0, 1])  # [..., batch_size, beam_size]
          # use 0 to copy to avoid wrong shape
          x = nn.reshape(
              x, shape=[0] *
              (len(x.shape) - 2) + [-1])  # [..., batch_size * beam_size]
          x = nn.transpose(
              x, [len(x.shape) - 1] +
              list(range(0, len(x.shape) - 1)))  # [batch_size * beam_size, ...]
          return x
function_tokens: def tile_beam_merge_with_batch ( x , beam_size ) : check_type ( x , 'x' , ( Variable ) , 'BeamSearchDecoder.tile_beam_merge_with_batch' ) x = nn . unsqueeze ( x , [ 1 ] ) # [batch_size, 1, ...] expand_times = [ 1 ] * len ( x . shape ) expand_times [ 1 ] = beam_size x = paddle . tile ( x , expand_times ) # [batch_size, beam_size, ...] x = nn . transpose ( x , list ( range ( 2 , len ( x . shape ) ) ) + [ 0 , 1 ] ) # [..., batch_size, beam_size] # use 0 to copy to avoid wrong shape x = nn . reshape ( x , shape = [ 0 ] * ( len ( x . shape ) - 2 ) + [ - 1 ] ) # [..., batch_size * beam_size] x = nn . transpose ( x , [ len ( x . shape ) - 1 ] + list ( range ( 0 , len ( x . shape ) - 1 ) ) ) # [batch_size * beam_size, ...] return x