class_docstr: Class for training and inference examples for BERT.
  
  Attributes:
      features: Feature dictionary.
class_docstr_tok: ["Class","for","training","and","inference","examples","for","BERT",".","Attributes",":","features",":","Feature","dictionary","."]
docstr: Inputs to the example wrapper
  
  Args:
      input_ids: indices of single characters (treated as subwords)
      input_mask: list of bools with 0s in place of input_ids to be masked
      segment_ids: list of ints from 0 to 10 to denote the text segment type (
          0 - for tokens of ASR hypothesis, 
          1 - for tokens of the first candidate
          ...
          10 - for tokens of the tenth candidate
      )
      input_ids_for_subwords: indices of real subwords (as tokenized by bert tokenizer)
      input_mask_for_subwords: list of bools with 0s in place of input_ids_for_subwords to be masked
      segment_ids_for_subwords: same as segment_ids but for input_ids_for_subwords
      character_pos_to_subword_pos: list of size=len(input_ids), value=(position of corresponding subword in input_ids_for_subwords) 
      fragment_indices: list of tuples (start_position, end_position, candidate_id), end is exclusive, candidate_id can be -1 if not set
      labels_mask: bool tensor with 0s in place of label tokens to be masked
      labels: indices of semiotic classes which should be predicted from each of the
          corresponding input tokens
      spans: list of tuples (class_id, start_position, end_position), end is exclusive, class is always 1(CUSTOM)
      default_label: The default label
docstr_tok: ["Inputs","to","the","example","wrapper","Args",":","input_ids",":","indices","of","single","characters","(","treated","as","subwords",")","input_mask",":","list","of","bools","with","0s","in","place","of","input_ids","to","be","masked","segment_ids",":","list","of","ints","from","0","to","10","to","denote","the","text","segment","type","(","0","-","for","tokens","of","ASR","hypothesis",",","1","-","for","tokens","of","the","first","candidate","...","10","-","for","tokens","of","the","tenth","candidate",")","input_ids_for_subwords",":","indices","of","real","subwords","(","as","tokenized","by","bert","tokenizer",")","input_mask_for_subwords",":","list","of","bools","with","0s","in","place","of","input_ids_for_subwords","to","be","masked","segment_ids_for_subwords",":","same","as","segment_ids","but","for","input_ids_for_subwords","character_pos_to_subword_pos",":","list","of","size=len","(","input_ids",")",",","value=","(","position","of","corresponding","subword","in","input_ids_for_subwords",")","fragment_indices",":","list","of","tuples","(","start_position",",","end_position",",","candidate_id",")",",","end","is","exclusive",",","candidate_id","can","be","-1","if","not","set","labels_mask",":","bool","tensor","with","0s","in","place","of","label","tokens","to","be","masked","labels",":","indices","of","semiotic","classes","which","should","be","predicted","from","each","of","the","corresponding","input","tokens","spans",":","list","of","tuples","(","class_id",",","start_position",",","end_position",")",",","end","is","exclusive",",","class","is","always","1","(","CUSTOM",")","default_label",":","The","default","label"]
code: def __init__(
      self,
      input_ids: List[int],
      input_mask: List[int],
      segment_ids: List[int],
      input_ids_for_subwords: List[int],
      input_mask_for_subwords: List[int],
      segment_ids_for_subwords: List[int],
      character_pos_to_subword_pos: List[int],
      fragment_indices: List[Tuple[int, int, int]],
      labels_mask: List[int],
      labels: List[int],
      spans: List[Tuple[int, int, int]],
      default_label: int,
  ) -> None:
      """Inputs to the example wrapper
  
      Args:
          input_ids: indices of single characters (treated as subwords)
          input_mask: list of bools with 0s in place of input_ids to be masked
          segment_ids: list of ints from 0 to 10 to denote the text segment type (
              0 - for tokens of ASR hypothesis,
              1 - for tokens of the first candidate
              ...
              10 - for tokens of the tenth candidate
          )
          input_ids_for_subwords: indices of real subwords (as tokenized by bert tokenizer)
          input_mask_for_subwords: list of bools with 0s in place of input_ids_for_subwords to be masked
          segment_ids_for_subwords: same as segment_ids but for input_ids_for_subwords
          character_pos_to_subword_pos: list of size=len(input_ids), value=(position of corresponding subword in input_ids_for_subwords)
          fragment_indices: list of tuples (start_position, end_position, candidate_id), end is exclusive, candidate_id can be -1 if not set
          labels_mask: bool tensor with 0s in place of label tokens to be masked
          labels: indices of semiotic classes which should be predicted from each of the
              corresponding input tokens
          spans: list of tuples (class_id, start_position, end_position), end is exclusive, class is always 1(CUSTOM)
          default_label: The default label
      """
      input_len = len(input_ids)
      if not (
          input_len == len(input_mask)
          and input_len == len(segment_ids)
          and input_len == len(labels_mask)
          and input_len == len(labels)
          and input_len == len(character_pos_to_subword_pos)
      ):
          raise ValueError(
              "All feature lists should have the same length ({})".format(
                  input_len
              )
          )
  
      input_len_for_subwords = len(input_ids_for_subwords)
      if not (
          input_len_for_subwords == len(input_mask_for_subwords)
          and input_len_for_subwords == len(segment_ids_for_subwords)
      ):
          raise ValueError(
              "All feature lists for subwords should have the same length ({})".format(
                  input_len_for_subwords
              )
          )
  
      self.features = OrderedDict(
          [
              ("input_ids", input_ids),
              ("input_mask", input_mask),
              ("segment_ids", segment_ids),
              ("input_ids_for_subwords", input_ids_for_subwords),
              ("input_mask_for_subwords", input_mask_for_subwords),
              ("segment_ids_for_subwords", segment_ids_for_subwords),
              (
                  "character_pos_to_subword_pos",
                  character_pos_to_subword_pos,
              ),
              ("fragment_indices", fragment_indices),
              ("labels_mask", labels_mask),
              ("labels", labels),
              ("spans", spans),
          ]
      )
      self._default_label = default_label
  
file_path: NeMo/nemo/collections/nlp/data/spellchecking_asr_customization/bert_example.py
imports: import logging
  from collections import OrderedDict
  from os import path
  from typing import Dict, List, Optional, Tuple, Union
  from transformers import PreTrainedTokenizerBase
label_desc: Use image node_id 1 to create a new BertExample object from inherited base classes: object with example: obj = BertExample(input_ids, input_mask, segment_ids, input_ids_for_subwords, input_mask_for_subwords, segment_ids_for_subwords, character_pos_to_subword_pos, fragment_indices, labels_mask, labels, spans, default_label)