code: def get_long_tensor(tokens_list, batch_size, pad_id=constant.PAD_ID):
      """Convert (list of )+ tokens to a padded LongTensor."""
      sizes = []
      x = tokens_list
      while isinstance(x[0], list):
          sizes.append(max(len(y) for y in x))
          x = [z for y in x for z in y]
      # TODO: pass in a device parameter and put it directly on the relevant device?
      # that might be faster than creating it and then moving it
      tokens = torch.LongTensor(batch_size, *sizes).fill_(pad_id)
      for i, s in enumerate(tokens_list):
          tokens[i, : len(s)] = torch.LongTensor(s)
      return tokens
  
file_path: stanza/stanza/models/common/data.py
imports: import logging
  import random
  import torch
  import stanza.models.common.seq2seq_constant
  from stanza.models.common.doc import HEAD, ID, UPOS
label_desc: Use image node_id 2 for calling a global function with example usage: get_long_tensor(tokens_list, batch_size, pad_id) and returns: tokens