class_docstr: Produces BERT inputs and answer spans for Squad.
class_docstr_tok: ["Produces","BERT","inputs","and","answer","spans","for","Squad","."]
code: def _calculate_answer_indices(self, row, offset, start_idx, end_idx):
      # now map original answer spans to tokenized spans
      start_idx_map = {}
      end_idx_map = {}
      for tokenized_idx, (raw_start_idx, raw_end_idx) in enumerate(
          zip(start_idx[:-1], end_idx[:-1])
      ):
          start_idx_map[raw_start_idx] = tokenized_idx + offset
          end_idx_map[raw_end_idx] = tokenized_idx + offset
  
      answer_start_indices = [
          start_idx_map.get(raw_idx, self.SPAN_PAD_IDX)
          for raw_idx in row[self.answer_starts_column]
      ]
      answer_end_indices = [
          end_idx_map.get(raw_idx + len(answer), self.SPAN_PAD_IDX)
          for raw_idx, answer in zip(
              row[self.answer_starts_column], row[self.answers_column]
          )
      ]
      if not (answer_start_indices and answer_end_indices):
          # if there are no answers, we use the 0, 0 span.
          answer_start_indices = [0]
          answer_end_indices = [0]
  
      return answer_start_indices, answer_end_indices
  
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 4 for calling the SquadForBERTTensorizer obj's underlying member method code with example usage: obj._calculate_answer_indices(row, offset, start_idx, end_idx) and returns: answer_start_indices,  answer_end_indices