class_docstr: An interface between the Scenic DETR implementation and COCO evaluators.
class_docstr_tok: ["An","interface","between","the","Scenic","DETR","implementation","and","COCO","evaluators","."]
docstr: Add a single example to the evaluator.
  
  Args:
    task_name: Name of the task, e.g., layout.
    ds_name: Name of the dataset, e.g., rico.
    prediction: Model prediction dictionary with key 'pred_logits', in shape
      of `[num_objects, num_classes]`.
    target: Target dictionary with key 'labels'.
docstr_tok: ["Add","a","single","example","to","the","evaluator",".","Args",":","task_name",":","Name","of","the","task",",","e.g.",",","layout",".","ds_name",":","Name","of","the","dataset",",","e.g.",",","rico",".","prediction",":","Model","prediction","dictionary","with","key","'pred_logits","'",",","in","shape","of","`","[","num_objects",",","num_classes","]","`",".","target",":","Target","dictionary","with","key","'labels","'","."]
code: def add_example(
      self,
      task_name: str,
      ds_name: str,
      prediction: Dict[str, np.ndarray],
      target: Dict[str, np.ndarray],
  ):
      """Add a single example to the evaluator.
  
      Args:
        task_name: Name of the task, e.g., layout.
        ds_name: Name of the dataset, e.g., rico.
        prediction: Model prediction dictionary with key 'pred_logits', in shape
          of `[num_objects, num_classes]`.
        target: Target dictionary with key 'labels'.
      """
      # Get result lists for the (task, dataset) pair.
      labels, preds = self._get_result_lists(task_name, ds_name)
  
      # Get valid (non-padding) target size.
      valid_index = [i for i, l in enumerate(target["labels"]) if l > 0]
  
      target_size = len(valid_index)
      if target_size == 0:
          # Ignore empty examples.
          return
  
      target_labels = target["labels"][valid_index]
      labels += target_labels.tolist()
  
      pred_labels = np.argmax(prediction["pred_logits"], axis=-1)
      preds += pred_labels[valid_index].tolist()
      self._num_examples_added[(task_name, ds_name)] += 1
  
      if "binary_pred_logits" in prediction:
          labels, preds = self._get_result_lists(
              f"binary_{task_name}", ds_name
          )
          target_labels = target["binary_labels"][valid_index]
          labels += target_labels.tolist()
          pred_labels = np.argmax(
              prediction["binary_pred_logits"], axis=-1
          )
          preds += pred_labels[valid_index].tolist()
          self._num_examples_added[
              (f"binary_{task_name}", ds_name)
          ] += 1
  
imports: import collections
  import copy
  import functools
  from typing import Any, Dict, Mapping, Optional, Sequence, Tuple, Union
  from absl import logging
  import flax
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.common_lib import debug_utils
  from scenic.train_lib_deprecated import optimizers
  from scenic.train_lib_deprecated import train_utils
label_desc: Use image node_id 3 for calling the LayoutDenoiseGlobalEvaluator obj's underlying member method code with example usage: obj.add_example(task_name, ds_name, prediction, target) without return types