class_docstr: Class for few-shot evaluation.
class_docstr_tok: ["Class","for","few-shot","evaluation","."]
docstr: Call `writer` with a descriptive string and the results.
docstr_tok: ["Call","`","writer","`","with","a","descriptive","string","and","the","results","."]
code: def log_fewshot_summary(
      self,
      writer: metric_writers.MetricWriter,
      step: int,
      results: Tuple[train_utils.PyTree, train_utils.PyTree],
      prefix_detailed: str = "zz_fewshot_detailed",
      prefix_best_l2: str = "fewshot",
      prefix_highlight: str = "fewshot_main",
      flush_writer: bool = True,
  ):
      """Call `writer` with a descriptive string and the results."""
      results, best_l2 = results
      scalars = {}
  
      # First, go through each individual result:
      for dataset_name, result in results.items():
          for (shots, l2), acc in result.items():
              scalars[
                  f"{prefix_detailed}/{dataset_name}_{shots}shot_l2={l2}"
              ] = acc
  
      # Second, report each dataset/shot with the single 'globally' best l2.
      for shots, l2 in best_l2.items():
          scalars[
              f"{prefix_detailed}/best_l2_for_{shots}shot_video_eval"
          ] = l2
  
          for dataset_name, result in results.items():
              value = result[shots, l2]
              scalars[
                  f"{prefix_best_l2}/{dataset_name}_{shots}shot"
              ] = value
  
      # And a highlight, if desired:
      if self.walk_first:
          dataset_name, shots = self.walk_first
          l2 = best_l2[shots]
          value = results[dataset_name][shots, l2]
          scalars[
              f"{prefix_highlight}/{dataset_name}_{shots}shot"
          ] = value
  
      writer.write_scalars(step, scalars)
      if flush_writer:
          writer.flush()
  
imports: import functools
  from typing import Any, Optional, Tuple
  from absl import logging
  from clu import metric_writers
  from flax import jax_utils
  import jax
  import jax.numpy
  import numpy
  from scenic.dataset_lib import dataset_utils
  from scenic.dataset_lib.big_transfer import builder
  from scenic.train_lib import train_utils
  import tensorflow_datasets
label_desc: Use image node_id 6 for calling the FewShotEvaluatorVideo obj's underlying member method code with example usage: obj.log_fewshot_summary(writer, step, results, prefix_detailed, prefix_best_l2, prefix_highlight, flush_writer) without return types