class_docstr: Tokenize text to sub-tokens, encode sub-tokens with their indices, create tokens and segment masks for ranking.
  
  Builds features for a pair of context with each of the response candidates.
class_docstr_tok: ["Tokenize","text","to","sub-tokens",",","encode","sub-tokens","with","their","indices",",","create","tokens","and","segment","masks","for","ranking",".","Builds","features","for","a","pair","of","context","with","each","of","the","response","candidates","."]
docstr: Tokenize and create masks.
  
  Args:
      batch: list of elements where the first element represents the batch with contexts
          and the rest of elements represent response candidates batches
  
  Returns:
      list of feature batches with subtokens, subtoken ids, subtoken mask, segment mask.
docstr_tok: ["Tokenize","and","create","masks",".","Args",":","batch",":","list","of","elements","where","the","first","element","represents","the","batch","with","contexts","and","the","rest","of","elements","represent","response","candidates","batches","Returns",":","list","of","feature","batches","with","subtokens",",","subtoken","ids",",","subtoken","mask",",","segment","mask","."]
code: def __call__(
      self, batch: List[List[str]]
  ) -> List[List[InputFeatures]]:
      """Tokenize and create masks.
  
      Args:
          batch: list of elements where the first element represents the batch with contexts
              and the rest of elements represent response candidates batches
  
      Returns:
          list of feature batches with subtokens, subtoken ids, subtoken mask, segment mask.
      """
  
      if isinstance(batch[0], str):
          batch = [batch]
  
      cont_resp_pairs = []
      if len(batch[0]) == 1:
          contexts = batch[0]
          responses_empt = [None] * len(batch)
          cont_resp_pairs.append(zip(contexts, responses_empt))
      else:
          contexts = [el[0] for el in batch]
          for i in range(1, len(batch[0])):
              responses = []
              for el in batch:
                  responses.append(el[i])
              cont_resp_pairs.append(zip(contexts, responses))
  
      input_features = []
  
      for s in cont_resp_pairs:
          sub_list_features = []
          for context, response in s:
              encoded_dict = self.tokenizer.encode_plus(
                  text=context,
                  text_pair=response,
                  add_special_tokens=True,
                  max_length=self.max_seq_length,
                  pad_to_max_length=True,
                  return_attention_mask=True,
                  return_tensors="pt",
              )
  
              curr_features = InputFeatures(
                  input_ids=encoded_dict["input_ids"],
                  attention_mask=encoded_dict["attention_mask"],
                  token_type_ids=encoded_dict["token_type_ids"],
                  label=None,
              )
              sub_list_features.append(curr_features)
          input_features.append(sub_list_features)
  
      return input_features
  
imports: import math
  import random
  import re
  from collections import defaultdict
  from dataclasses import dataclass
  from logging import getLogger
  from pathlib import Path
  from typing import Tuple, List, Optional, Union, Dict, Set, Any
  import nltk
  import numpy
  import torch
  from transformers import AutoTokenizer
  from transformers.data.processors.utils import InputFeatures
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.utils import zero_pad
  from deeppavlov.core.models.component import Component
  from deeppavlov.models.preprocessors.mask import Mask
label_desc: Use image node_id 1 for calling the TorchBertRankerPreprocessor obj's underlying member method code with example usage: obj.__call__(batch) and returns: input_features