class_docstr: An example for training/inference.
class_docstr_tok: ["An","example","for","training\/inference","."]
docstr: Add utterance related features input to InputExample.
  
  Note: this method modifies the system tokens and user_tokens in place to
  make their total length <= the maximum input length for BERT model.
  
  Args:
    system_tokens: a list of strings which represents schema description.
    system_inv_alignments: a list of tuples which denotes the start and end
      charater of the tpken that a bert token originates from in the original
      schema description.
    user_tokens: a list of strings which represents utterance.
    user_inv_alignments: a list of tuples which denotes the start and end
      charater of the token that a bert token originates from in the original
      system and user utterance.
docstr_tok: ["Add","utterance","related","features","input","to","InputExample",".","Note",":","this","method","modifies","the","system","tokens","and","user_tokens","in","place","to","make","their","total","length","<","=","the","maximum","input","length","for","BERT","model",".","Args",":","system_tokens",":","a","list","of","strings","which","represents","schema","description",".","system_inv_alignments",":","a","list","of","tuples","which","denotes","the","start","and","end","charater","of","the","tpken","that","a","bert","token","originates","from","in","the","original","schema","description",".","user_tokens",":","a","list","of","strings","which","represents","utterance",".","user_inv_alignments",":","a","list","of","tuples","which","denotes","the","start","and","end","charater","of","the","token","that","a","bert","token","originates","from","in","the","original","system","and","user","utterance","."]
code: def add_utterance_features(
      self,
      system_tokens,
      system_inv_alignments,
      user_tokens,
      user_inv_alignments,
      system_utterance,
      user_utterance,
  ):
      """Add utterance related features input to InputExample.
  
      Note: this method modifies the system tokens and user_tokens in place to
      make their total length <= the maximum input length for BERT model.
  
      Args:
        system_tokens: a list of strings which represents schema description.
        system_inv_alignments: a list of tuples which denotes the start and end
          charater of the tpken that a bert token originates from in the original
          schema description.
        user_tokens: a list of strings which represents utterance.
        user_inv_alignments: a list of tuples which denotes the start and end
          charater of the token that a bert token originates from in the original
          system and user utterance.
      """
      # Input sequence length for utterance BERT encoder
      max_utt_len = self._max_seq_length
  
      # Modify lengths of schema description & utterance so that length of total utt
      # (including cls_token, setp_token, sep_token) is no more than max_utt_len
      is_too_long = truncate_seq_pair(
          system_tokens, user_tokens, max_utt_len - 3
      )
      if is_too_long:
          logging.debug(
              f"Utterance sequence truncated in example id - {self.example_id} from {len(system_tokens) + len(user_tokens)}."
          )
  
      # Construct the tokens, segment mask and valid token mask which will be
      # input to BERT, using the tokens for schema description (sequence A) and
      # system and user utterance (sequence B).
      utt_subword = []
      utt_seg = []
      utt_mask = []
      start_char_idx = []
      end_char_idx = []
  
      utt_subword.append(self._tokenizer.cls_token)
      utt_seg.append(0)
      utt_mask.append(1)
      start_char_idx.append(0)
      end_char_idx.append(0)
  
      for subword_idx, subword in enumerate(system_tokens):
          utt_subword.append(subword)
          utt_seg.append(0)
          utt_mask.append(1)
          st, en = system_inv_alignments[subword_idx]
          start_char_idx.append(-(st + 1))
          end_char_idx.append(-(en + 1))
  
      utt_subword.append(self._tokenizer.sep_token)
      utt_seg.append(0)
      utt_mask.append(1)
      start_char_idx.append(0)
      end_char_idx.append(0)
  
      for subword_idx, subword in enumerate(user_tokens):
          utt_subword.append(subword)
          utt_seg.append(1)
          utt_mask.append(1)
          st, en = user_inv_alignments[subword_idx]
          start_char_idx.append(st + 1)
          end_char_idx.append(en + 1)
  
      utt_subword.append(self._tokenizer.sep_token)
      utt_seg.append(1)
      utt_mask.append(1)
      start_char_idx.append(0)
      end_char_idx.append(0)
  
      utterance_ids = self._tokenizer.tokens_to_ids(utt_subword)
  
      # Zero-pad up to the BERT input sequence length.
      while len(utterance_ids) < max_utt_len:
          utterance_ids.append(0)
          utt_seg.append(0)
          utt_mask.append(0)
          start_char_idx.append(0)
          end_char_idx.append(0)
      self.utterance_ids = utterance_ids
      self.utterance_segment = utt_seg
      self.utterance_mask = utt_mask
      self.start_char_idx = start_char_idx
      self.end_char_idx = end_char_idx
  
      self.user_utterance = user_utterance
      self.system_utterance = system_utterance
  
file_path: NeMo/nemo/collections/nlp/data/dialogue/input_example/sgd_input_example.py
imports: from typing import List
  from nemo.collections.nlp.data.dialogue.input_example.input_example import DialogueInputExample
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling the SGDInputExample obj's underlying member method code with example usage: obj.add_utterance_features(system_tokens, system_inv_alignments, user_tokens, user_inv_alignments, system_utterance, user_utterance) without return types