code: def get_pair_text_tokens(
      item: Dict[str, Any], masked_token_processor: MaskedTokenProcessor
  ) -> Dict[str, torch.Tensor]:
      """Given an item Dict with either 1 or 2 text sentences,
      tokenize and concat them returning a Dict that contains at least
      "input_ids", "input_mask", and "segment_ids'.
  
      Args:
          item (Dict[str, Any]):
              A Dict containing keys
              "text" or "tokens", and optionally "text_b"
          masked_token_processor (MaskedTokenProcessor):
              A processor used to tokenize the texts.
  
      Returns:
          [Dict[str, torch.Tensor]]:
              A Dict containing tokenized texts and
              related tensors.
      """
      if "text" in item:
          text_a = item["text"]
      elif "text_a" in item:
          text_a = item["text_a"]
      else:
          text_a = " ".join(item["tokens"])
  
      if isinstance(text_a, list):
          text_a = " ".join(text_a)
  
      tokens_a = masked_token_processor.tokenize(text_a)
  
      # 'text_b' can be defined in the dataset preparation
      tokens_b = None
      if "text_b" in item:
          text_b = item["text_b"]
          if text_b:
              tokens_b = masked_token_processor.tokenize(text_b)
  
      masked_token_processor._truncate_seq_pair(
          tokens_a, tokens_b, masked_token_processor._max_seq_length
      )
      output = masked_token_processor._convert_to_indices(
          tokens_a,
          tokens_b,
          probability=masked_token_processor._probability,
      )
      return output
  
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 1 for calling a global function with example usage: get_pair_text_tokens(item, masked_token_processor) and returns: output