code: def tensorize(
      self,
      texts: Optional[List[List[str]]] = None,
      tokens: Optional[List[List[List[str]]]] = None,
      languages: Optional[List[List[str]]] = None,
  ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
      # unwrap Optional
      batch_size: int = self.batch_size(texts, tokens)
      row_size: int = self.row_size(texts, tokens)
  
      if languages is None:
          languages = [[self.default_language] * row_size] * batch_size
  
      tokens_2d: List[List[int]] = []
      languages_2d: List[List[int]] = []
      seq_len_2d: List[int] = []
      positions_2d: List[List[int]] = []
  
      for idx in range(batch_size):
          numberized: Tuple[
              List[int], List[int], int, List[int]
          ] = self.numberize(
              self.get_texts_by_index(texts, idx),
              self.get_tokens_by_index(tokens, idx),
              languages[idx],
          )
          tokens_2d.append(numberized[0])
          languages_2d.append(numberized[1])
          seq_len_2d.append(numberized[2])
          positions_2d.append(numberized[3])
  
      tokens, pad_mask = pad_2d_mask(
          tokens_2d,
          pad_value=self.token_vocab.pad_idx,
          seq_padding_control=self.seq_padding_control,
          max_seq_pad_len=self.max_seq_len,
          batch_padding_control=self.batch_padding_control,
      )
  
      languages, _ = pad_2d_mask(
          languages_2d,
          pad_value=0,
          seq_padding_control=self.seq_padding_control,
          max_seq_pad_len=self.max_seq_len,
          batch_padding_control=self.batch_padding_control,
      )
  
      positions, _ = pad_2d_mask(
          positions_2d,
          pad_value=0,
          seq_padding_control=self.seq_padding_control,
          max_seq_pad_len=self.max_seq_len,
          batch_padding_control=self.batch_padding_control,
      )
  
      if self.device == "":
          return tokens, pad_mask, languages, positions
      else:
          return (
              tokens.to(self.device),
              pad_mask.to(self.device),
              languages.to(self.device),
              positions.to(self.device),
          )
  
file_path: pytext/pytext/torchscript/tensorizer/xlm.py
imports: from typing import List, Optional, Tuple
  import torch
  from pytext.torchscript.utils import pad_2d_mask
  from pytext.torchscript.vocab import ScriptVocabulary
  from .tensorizer import ScriptTensorizer, VocabLookup
label_desc: Use image node_id 5 for calling the ScriptXLMTensorizer obj's underlying member method code with example usage: obj.tensorize(texts, tokens, languages) and returns: tokens,  pad_mask,  languages,  positions, tokens,  pad_mask,  languages,  positions