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
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