class_docstr: Methods numberize() and tensorize() implement https://fburl.com/an4fv7m1.
class_docstr_tok: ["Methods","numberize","(",")","and","tensorize","(",")","implement","https",":","\/\/fburl.com\/an4fv7m1","."]
docstr: This function contains logic for converting tokens into ids based on
  the specified vocab. It also outputs, for each instance, the vectors
  needed to run the actual model. It works off of one sample.
docstr_tok: ["This","function","contains","logic","for","converting","tokens","into","ids","based","on","the","specified","vocab",".","It","also","outputs",",","for","each","instance",",","the","vectors","needed","to","run","the","actual","model",".","It","works","off","of","one","sample","."]
code: def numberize(self, row: Dict) -> Tuple[Any, ...]:
      """
      This function contains logic for converting tokens into ids based on
      the specified vocab. It also outputs, for each instance, the vectors
      needed to run the actual model. It works off of one sample.
      """
      # don't include passage id
      positive_ctx = row["positive_ctx"][:-1]
      positive_ctx_tokens = [
          self.tokenizer.tokenize(content) for content in positive_ctx
      ]
      (
          positive_ctx_token_ids,
          positive_ctx_segment_labels,
          positive_ctx_seq_len,
          positive_ctx_positions,
      ) = self.tensorizer_script_impl.numberize(positive_ctx_tokens)
  
      # don't include passage id
      negative_ctxs = [
          neg_ctx[:-1] for neg_ctx in row["negative_ctxs"]
      ]  # returns List[str]
      if negative_ctxs and row["num_negative_ctx"] == 1:
          # currently only num_negative_ctx == 1 is supported
          negative_ctx_tokens = [
              self.tokenizer.tokenize(content)
              for content in negative_ctxs[0]
          ]
          (
              negative_ctx_token_ids,
              negative_ctx_segment_labels,
              negative_ctx_seq_len,
              negative_ctx_positions,
          ) = self.tensorizer_script_impl.numberize(negative_ctx_tokens)
      else:
          negative_ctx_token_ids = []
          negative_ctx_segment_labels = []
          negative_ctx_seq_len = 0
          negative_ctx_positions = []
  
      return (
          positive_ctx_token_ids,
          positive_ctx_segment_labels,
          positive_ctx_seq_len,
          positive_ctx_positions,
          negative_ctx_token_ids,
          negative_ctx_segment_labels,
          negative_ctx_seq_len,
          negative_ctx_positions,
      )
  
imports: from typing import Any, Dict, List, Optional, Tuple
  from pytext.common.constants import SpecialTokens
  from pytext.config.component import ComponentType, create_component
  from pytext.data.bert_tensorizer import BERTTensorizer, build_fairseq_vocab
  from pytext.data.roberta_tensorizer import RoBERTaTensorizer
  from pytext.data.tensorizers import LabelTensorizer
  from pytext.data.tokenizers import Tokenizer
  from pytext.data.utils import Vocabulary
  from pytext.utils.file_io import PathManager
label_desc: Use image node_id 1 for calling the BERTContextTensorizerForDenseRetrieval obj's underlying member method code with example usage: obj.numberize(row) and returns: positive_ctx_token_ids,  positive_ctx_segment_labels,  positive_ctx_seq_len,  positive_ctx_positions,  negative_ctx_token_ids,  negative_ctx_segment_labels,  negative_ctx_seq_len,  negative_ctx_positions