class_docstr: Class for BERT few-shot evaluation.
class_docstr_tok: ["Class","for","BERT","few-shot","evaluation","."]
docstr: Compute summary over all `datasets` that comes from config.
docstr_tok: ["Compute","summary","over","all","`","datasets","`","that","comes","from","config","."]
code: def run_all(self, train_state, datasets):
      """Compute summary over all `datasets` that comes from config."""
      results = {}
      for cfg in datasets:
          results[
              cfg.dataset_configs.task
          ] = self.compute_fewshot_metrics(train_state, cfg)
  
      # Now also figure out the regularization parameter that works best across
      # all datasets, per-shot. Similar to ATARI benchmark requiring one single
      # hyper-param across tasks, or BiT-HyperRule defining one clear thing.
      # Avoids over-fitting to a single task by selecting on test there, while
      # also avoiding the need to do cross-validation runs for each task.
      best_l2 = {}
      for shots in self.shots:
          reg_ranks = []
          for _, res in results.items():
              reg_accus = [res[shots, l2] for l2 in self.l2_regs]
              reg_ranks.append(np.argsort(np.argsort(reg_accus)))
          best_l2[shots] = self.l2_regs[
              np.argmax(np.mean(reg_ranks, axis=0))
          ]
  
      return results, best_l2
  
imports: import functools
  from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
  from absl import logging
  from clu import metric_writers
  import flax
  from flax import jax_utils
  import flax.linen
  import jax
  import jax.numpy
  import jax.profiler
  import ml_collections
  import numpy
  from scenic.common_lib import debug_utils
  from scenic.train_lib import optimizers
  from scenic.train_lib import train_utils
  import scipy
  import sklearn.metrics
label_desc: Use image node_id 5 for calling the BERTFewShotEvaluator obj's underlying member method code with example usage: obj.run_all(train_state, datasets) and returns: results,  best_l2