code: def batch_encode(self, iterator, *args, dim=0, **kwargs):
          
          return stack_and_pad_tensors(
              super().batch_encode(iterator), padding_index=self.padding_index, dim=dim)
docs: Args:
              iterator (iterator): Batch of text to encode.
              *args: Arguments passed onto ``Encoder.__init__``.
              dim (int, optional): Dimension along which to concatenate tensors.
              **kwargs: Keyword arguments passed onto ``Encoder.__init__``.
  
          Returns
              torch.Tensor, list of int: Encoded and padded batch of sequences; Original lengths of
                  sequences.