code: def pad_and_tensorize(
      batch, pad_token=0, pad_shape=None, dtype=torch.long
  ):
      batch = list(batch)
      if not batch:
          return torch.Tensor()
  
      return cuda.tensor(
          pad(batch, pad_token=pad_token, pad_shape=pad_shape),
          dtype=dtype,
      )
  
imports: import itertools
  from collections import Counter
  from typing import Dict, List, Optional, Tuple
  import torch
  from pytext.common.constants import SpecialTokens, Token
  from pytext.utils import cuda, precision
label_desc: Use image node_id 5 for calling a global function with example usage: pad_and_tensorize(batch, pad_token, pad_shape, dtype) and returns: cuda, torch