def prepare_data(seqs_x, seqs_y=None, cuda=False, batch_first=True):
    "\n    Args:\n        eval ('bool'): indicator for eval/infer.\n\n    Returns:\n\n    "

    def _np_pad_batch_2D(samples, pad, batch_first=True, cuda=True):
        batch_size = len(samples)
        sizes = [len(s) for s in samples]
        max_size = max(sizes)
        x_np = np.full((batch_size, max_size), fill_value=pad, dtype='int64')
        for ii in range(batch_size):
            x_np[ii, :sizes[ii]] = samples[ii]
        if (batch_first is False):
            x_np = np.transpose(x_np, [1, 0])
        x = torch.tensor(x_np)
        if (cuda is True):
            x = x.cuda()
        return x
    seqs_x = list(map((lambda s: (([BOS] + s) + [EOS])), seqs_x))
    x = _np_pad_batch_2D(samples=seqs_x, pad=PAD, cuda=cuda, batch_first=batch_first)
    if (seqs_y is None):
        return x
    seqs_y = list(map((lambda s: (([BOS] + s) + [EOS])), seqs_y))
    y = _np_pad_batch_2D(seqs_y, pad=PAD, cuda=cuda, batch_first=batch_first)
    return (x, y)
Args:
    eval ('bool'): indicator for eval/infer.

Returns:
def prepare_data(seqs_x, seqs_y=None, cuda=False, batch_first=True):
    "\n    Args:\n        eval ('bool'): indicator for eval/infer.\n\n    Returns:\n\n    "

    def _np_pad_batch_2D(samples, pad, batch_first=True, cuda=True):
        batch_size = len(samples)
        sizes = [len(s) for s in samples]
        max_size = max(sizes)
        x_np = np.full((batch_size, max_size), fill_value=pad, dtype='int64')
        for ii in range(batch_size):
            x_np[ii, :sizes[ii]] = samples[ii]
        if (batch_first is False):
            x_np = np.transpose(x_np, [1, 0])
        x = torch.tensor(x_np)
        if (cuda is True):
            x = x.cuda()
        return x
    seqs_x = list(map((lambda s: (([BOS] + s) + [EOS])), seqs_x))
    x = _np_pad_batch_2D(samples=seqs_x, pad=PAD, cuda=cuda, batch_first=batch_first)
    if (seqs_y is None):
        return x
    seqs_y = list(map((lambda s: (([BOS] + s) + [EOS])), seqs_y))
    y = _np_pad_batch_2D(seqs_y, pad=PAD, cuda=cuda, batch_first=batch_first)
    return (x, y)