class_docstr: ReCoRD example accumulator
  
  Attributes:
      examples_processed: total number of examples processed so far
      record_counter: number of examples processed for each index
      nested_len: expected number of flat examples for a given index
      flat_examples: stores flat examples
      nested_examples: stores nested examples
      collected_indices: indices of collected nested examples
      returned_indices: indices that have been returned
class_docstr_tok: ["ReCoRD","example","accumulator","Attributes",":","examples_processed",":","total","number","of","examples","processed","so","far","record_counter",":","number","of","examples","processed","for","each","index","nested_len",":","expected","number","of","flat","examples","for","a","given","index","flat_examples",":","stores","flat","examples","nested_examples",":","stores","nested","examples","collected_indices",":","indices","of","collected","nested","examples","returned_indices",":","indices","that","have","been","returned"]
docstr: Combines a list of flat examples denoted by the given index into a single nested example
  provided that all the necessary flat example have been collected by this time.
  Args:
      index: the index of the candidate nested example
docstr_tok: ["Combines","a","list","of","flat","examples","denoted","by","the","given","index","into","a","single","nested","example","provided","that","all","the","necessary","flat","example","have","been","collected","by","this","time",".","Args",":","index",":","the","index","of","the","candidate","nested","example"]
code: def collect_nested_example(self, index: str):
      """Combines a list of flat examples denoted by the given index into a single nested example
      provided that all the necessary flat example have been collected by this time.
      Args:
          index: the index of the candidate nested example
      """
      if self.ready_to_nest(index):
          example_list: List[RecordFlatExample] = self.flat_examples[
              index
          ]
          entities: List[str] = []
          labels: List[int] = []
          probabilities: List[float] = []
          answers: List[str] = []
  
          for example in example_list:
              entities.append(example.entity)
              labels.append(example.label)
              probabilities.append(example.probability)
              if example.label == 1:
                  answers.append(example.entity)
  
          prediction_index = np.argmax(probabilities)
          prediction = entities[prediction_index]
  
          self.nested_examples[index] = RecordNestedExample(
              index, prediction, answers
          )
          self.collected_indices.add(index)
  
imports: import math
  import random
  import re
  from collections import defaultdict
  from dataclasses import dataclass
  from logging import getLogger
  from pathlib import Path
  from typing import Tuple, List, Optional, Union, Dict, Set, Any
  import nltk
  import numpy
  import torch
  from transformers import AutoTokenizer
  from transformers.data.processors.utils import InputFeatures
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.utils import zero_pad
  from deeppavlov.core.models.component import Component
  from deeppavlov.models.preprocessors.mask import Mask
label_desc: Use image node_id 4 for calling the RecordExampleAccumulator obj's underlying member method code with example usage: obj.collect_nested_example(index) without return types