def METHOD_NAME(var, indices):
    """Gather slices from var in each batch, according to corresponding
    index in indices. Currently, it only support 2d Tensor.
    Args:
        var (Variable): with shape [batch_size, ...]
        indices (Variable): with shape [batch_size, max_len]
    Returns: Variable with shape [batch_size]
    Raises: NULL
    Examples:
        var
            [[1, 2, 3],
             [4, 5, 6]]
        indices
            [[2, 0], [1, 2]]
        return
            [[3, 1], [5, 6]]
    """
    if len(indices.shape) != 2:
        raise ValueError(
            "shape of indices error. it should be a 2-D layers. " "but got shape = %s" % (str(indices.shape),)
        )
    batch_size = paddle.shape(indices)[0]
    zero = paddle.to_tensor([0], dtype="int64")
    one = paddle.to_tensor([1], dtype="int64")
    end = paddle.cast(batch_size, dtype="int64")
    batch_indices_1d = paddle.unsqueeze(paddle.arange(zero, end, one, dtype=indices.dtype), [1])
    seq_len = indices.shape[1]
    batch_indices = paddle.expand(batch_indices_1d, [batch_size, seq_len])
    coord_2d = paddle.concat([paddle.unsqueeze(batch_indices, [2]), paddle.unsqueeze(indices, [2])], axis=2)
    coord_2d.stop_gradient = True
    coord_1d = paddle.reshape(coord_2d, shape=[-1, 2])
    output_1d = paddle.gather_nd(var, coord_1d)
    output_2d = paddle.reshape(output_1d, [batch_size, seq_len, var.shape[-1]])
    return output_2d