class_docstr: Produces BERT inputs and answer spans for Squad.
class_docstr_tok: ["Produces","BERT","inputs","and","answer","spans","for","Squad","."]
code: def tensorize(self, batch):
      (
          tokens,
          segment_labels,
          seq_len,
          positions,
          answer_start_idx,
          answer_end_idx,
      ) = zip(*batch)
      tokens = pad_and_tensorize(tokens, self.vocab.get_pad_index())
      segment_labels = pad_and_tensorize(
          segment_labels, self.vocab.get_pad_index()
      )
      pad_mask = (tokens != self.vocab.get_pad_index()).long()
      positions = pad_and_tensorize(positions)
      answer_start_idx = pad_and_tensorize(
          answer_start_idx, self.SPAN_PAD_IDX
      )
      answer_end_idx = pad_and_tensorize(
          answer_end_idx, self.SPAN_PAD_IDX
      )
      return (
          tokens,
          pad_mask,
          segment_labels,
          positions,
          answer_start_idx,
          answer_end_idx,
      )
  
imports: import itertools
  from typing import List
  import torch
  from pytext.data.bert_tensorizer import BERTTensorizer
  from pytext.data.roberta_tensorizer import RoBERTaTensorizer
  from pytext.data.tensorizers import lookup_tokens
  from pytext.data.utils import pad_and_tensorize
  from pytext.torchscript.tensorizer import ScriptRoBERTaTensorizerWithIndices
  from pytext.torchscript.vocab import ScriptVocabulary
label_desc: Use image node_id 6 for calling the SquadForBERTTensorizer obj's underlying member method code with example usage: obj.tensorize(batch) and returns: tokens,  pad_mask,  segment_labels,  positions,  answer_start_idx,  answer_end_idx