docstr: Converts a single `Example` into a single `Record`.
docstr_tok: ["Converts","a","single","`","Example","`","into","a","single","`","Record","`","."]
code: def _convert_example_to_record(
      self,
      example: InputExample,
      max_seq_length: int,
      tokenizer: Generic,
      phase: str = None,
  ) -> namedtuple:
      """Converts a single `Example` into a single `Record`."""
  
      text_a = tokenization.convert_to_unicode(example.text_a)
      tokens_a = tokenizer.tokenize(text_a)
      tokens_b = None
      if example.text_b is not None:
          # if 'text_b' in example._fields:
          text_b = tokenization.convert_to_unicode(example.text_b)
          tokens_b = tokenizer.tokenize(text_b)
  
      if tokens_b:
          # Modifies `tokens_a` and `tokens_b` in place so that the total
          # length is less than the specified length.
          # Account for [CLS], [SEP], [SEP] with '- 3'
          self._truncate_seq_pair(
              tokens_a, tokens_b, max_seq_length - 3
          )
      else:
          # Account for [CLS] and [SEP] with '- 2'
          if len(tokens_a) > max_seq_length - 2:
              tokens_a = tokens_a[0 : (max_seq_length - 2)]
  
      # The convention in BERT/ERNIE is:
      # (a) For sequence pairs:
      #  tokens:   [CLS] is this jack ##son ##ville ? [SEP] no it is not . [SEP]
      #  type_ids: 0     0  0    0    0     0       0 0     1  1  1  1   1 1
      # (b) For single sequences:
      #  tokens:   [CLS] the dog is hairy . [SEP]
      #  type_ids: 0     0   0   0  0     0 0
      #
      # Where 'type_ids' are used to indicate whether this is the first
      # sequence or the second sequence. The embedding vectors for `type=0` and
      # `type=1` were learned during pre-training and are added to the wordpiece
      # embedding vector (and position vector). This is not *strictly* necessary
      # since the [SEP] token unambiguously separates the sequences, but it makes
      # it easier for the model to learn the concept of sequences.
      #
      # For classification tasks, the first vector (corresponding to [CLS]) is
      # used as as the 'sentence vector'. Note that this only makes sense because
      # the entire model is fine-tuned.
      tokens = []
      text_type_ids = []
      tokens.append("[CLS]")
      text_type_ids.append(0)
      for token in tokens_a:
          tokens.append(token)
          text_type_ids.append(0)
      tokens.append("[SEP]")
      text_type_ids.append(0)
  
      if tokens_b:
          for token in tokens_b:
              tokens.append(token)
              text_type_ids.append(1)
          tokens.append("[SEP]")
          text_type_ids.append(1)
  
      token_ids = tokenizer.convert_tokens_to_ids(tokens)
      position_ids = list(range(len(token_ids)))
  
      if self.label_map:
          if example.label not in self.label_map:
              raise KeyError(
                  "example.label = {{{}}} not in label".format(
                      example.label
                  )
              )
          label_id = self.label_map[example.label]
      else:
          label_id = example.label
  
      if phase != "predict":
          record = self.Record_With_Label_Id(
              token_ids=token_ids,
              text_type_ids=text_type_ids,
              position_ids=position_ids,
              label_id=label_id,
          )
      else:
          record = self.Record_Wo_Label_Id(
              token_ids=token_ids,
              text_type_ids=text_type_ids,
              position_ids=position_ids,
          )
  
      return record
  
imports: from collections import namedtuple
  from typing import Callable, Generator, Generic, List
  import numpy
  from paddlehub.utils.log import logger
  from paddlehub.compat.task import tokenization
  from paddlehub.compat.task.batch import pad_batch_data
label_desc: Use image node_id 3 for calling the BaseNLPReader obj's underlying member method code with example usage: obj._convert_example_to_record(example, max_seq_length, tokenizer, phase) and returns: record