class_docstr: Benchmark class for Flax examples.
  
  This class overrides the behaviour of `self.assert*` methods to be
  deferred instead of failing immediately. This allows for using absltest
  assert methods for checking benchmark target metrics. This is also
  necessary for correctly reporting benchmark results and determining its
  success.
class_docstr_tok: ["Benchmark","class","for","Flax","examples",".","This","class","overrides","the","behaviour","of","`","self.assert","*","`","methods","to","be","deferred","instead","of","failing","immediately",".","This","allows","for","using","absltest","assert","methods","for","checking","benchmark","target","metrics",".","This","is","also","necessary","for","correctly","reporting","benchmark","results","and","determining","its","success","."]
docstr: Produce benchmark results report.
  
  Results are reported as a JSON string with the following schema:
  ```
  {
    "name": <class.testMethod>
    "succeeded": true / false
    "wall_time": float (containing wall-time for the benchmark)
    "metrics": {
      "string" -> float map of other performance metrics
    }
    "extras": {
      "string" -> "string" map containing anything else of interest
    }
  }
  ```
docstr_tok: ["Produce","benchmark","results","report",".","Results","are","reported","as","a","JSON","string","with","the","following","schema",":","``","`","{","``","name","''",":","<","class.testMethod",">","``","succeeded","''",":","true","\/","false","``","wall_time","''",":","float","(","containing","wall-time","for","the","benchmark",")","``","metrics","''",":","{","``","string","''","-",">","float","map","of","other","performance","metrics","}","``","extras","''",":","{","``","string","''","-",">","``","string","''","map","containing","anything","else","of","interest","}","}","``","`"]
code: def _report_benchmark_results(self):
      """Produce benchmark results report.
  
      Results are reported as a JSON string with the following schema:
      ```
      {
        "name": <class.testMethod>
        "succeeded": true / false
        "wall_time": float (containing wall-time for the benchmark)
        "metrics": {
          "string" -> float map of other performance metrics
        }
        "extras": {
          "string" -> "string" map containing anything else of interest
        }
      }
      ```
      """
      name = self._reported_name
      if not name:
          raise ValueError(
              "Unable to determine test name for reporting "
              "benchmark results. Make sure you are using "
              "`self.report_*` methods."
          )
  
      succeeded = not self.has_outstanding_fails()
      results = {
          "name": name,
          "succeeded": succeeded,
          "metrics": self._reported_metrics,
          "extras": self._reported_extras,
      }
      if self._reported_wall_time is not None:
          results["wall_time"] = self._reported_wall_time
      if not succeeded:
          msg = "\n".join(
              [str(fail) for fail in self._outstanding_fails]
          )
          results["extras"]["failed_assertions"] = msg
  
      results_str = json.dumps(results)
      logging.info(results_str)
  
      # Maybe save results as a file for pickup by CI / monitoring frameworks.
      benchmark_output_dir = FLAGS.benchmark_output_dir
      if benchmark_output_dir:
          filename = os.path.join(benchmark_output_dir, name + ".json")
          with io.GFile(filename, "w") as fout:
              fout.write(results_str)
  
imports: import functools
  import inspect
  import itertools
  import json
  import os
  import tempfile
  from typing import Dict
  from absl import flags, logging
  from absl.testing import absltest
  from tensorboard.backend.event_processing import directory_watcher, event_file_loader, io_wrapper
  from tensorboard.summary import v1
  from tensorboard.util import tensor_util
  from flax import io
label_desc: Use image node_id 15 for calling the Benchmark obj's underlying member method code with example usage: obj._report_benchmark_results() without return types