The code here will show you how to pad your tensors of different lengths into a single tensor used by pack_padded_sequence:

  
      github.com
  
  
    pytorch/pytorch/blob/master/test/test_nn.py#L1336-L1344 650

    self._test_Conv2d_naive_groups(torch.cuda.FloatTensor)


def test_batchnorm_eval(self):
    self._test_batchnorm_eval()


@unittest.skipIf(not TEST_CUDA, "CUDA unavailable")
def test_batchnorm_eval_cuda(self):
    self._test_batchnorm_eval(torch.cuda.FloatTensor)