docstr: BERT encodes
  - single sequence: ``[CLS] X [SEP]``
  - pair of sequences: ``[CLS] A [SEP] B [SEP]``
docstr_tok: ["BERT","encodes","-","single","sequence",":","``","[","CLS","]","X","[","SEP","]","``","-","pair","of","sequences",":","``","[","CLS","]","A","[","SEP","]","B","[","SEP","]","``"]
code: def _convert_to_indices(
      self,
      tokens_a: List[str],
      tokens_b: Optional[List[str]] = None,
      probability: float = 0.15,
  ) -> Dict[str, torch.Tensor]:
      """
      BERT encodes
      - single sequence: ``[CLS] X [SEP]``
      - pair of sequences: ``[CLS] A [SEP] B [SEP]``
      """
      input_ids_original, _, _, _ = self._token_transform(
          tokens_a, tokens_b
      )
  
      tokens_a, label_a = self._random_word(
          tokens_a, probability=probability
      )
      segment_ids = [0] * (len(tokens_a) + 2)
  
      if tokens_b:
          tokens_b, label_b = self._random_word(
              tokens_b, probability=probability
          )
          lm_label_ids = [-1] + label_a + [-1] + label_b + [-1]
          assert len(tokens_b) > 0
          segment_ids += [1] * (len(tokens_b) + 1)
      else:
          lm_label_ids = [-1] + label_a + [-1]
  
      (
          input_ids_masked,
          token_len,
          token_pad,
          tokens_masked,
      ) = self._token_transform(tokens_a, tokens_b)
  
      input_mask = [1] * token_len + [0] * token_pad
      segment_ids += [0] * token_pad
      lm_label_ids += [-1] * token_pad
  
      input_mask = torch.tensor(input_mask, dtype=torch.long)
      segment_ids = torch.tensor(segment_ids, dtype=torch.long)
      lm_label_ids = torch.tensor(lm_label_ids, dtype=torch.long)
      return {
          "input_ids_masked": input_ids_masked,  # specifically for MLM heads
          "input_ids": input_ids_original,  # unmasked tokens for CLIP heads
          # input_mask is non-padding (1) vs padding (0) mask (not MLM token masking)
          "input_mask": input_mask,
          "segment_ids": segment_ids,
          "lm_label_ids": lm_label_ids,
          "tokens_masked": tokens_masked,
      }
  
imports: import copy
  import random
  from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  from mmf.common.registry import registry
  from mmf.common.sample import Sample, SampleList
  from mmf.datasets.processors.processors import BaseProcessor
label_desc: Use image node_id 4 for calling the UNITERTextTokenizer obj's underlying member method code with example usage: obj._convert_to_indices(tokens_a, tokens_b, probability) and returns: dict