class_docstr: _PyTorchReducerContext is a component of the PyTorchTrialContext which does not interact with
  the rest of the PyTorchTrialContext.  It has been separated into its own object to keep the
  size of PyTorchTrialContext down, and because there may be a future where we can create a
  _PyTorchReducerContext as a standalone feature for users of the Core API... though in that
  case we would rename it with a public name first.
class_docstr_tok: ["_PyTorchReducerContext","is","a","component","of","the","PyTorchTrialContext","which","does","not","interact","with","the","rest","of","the","PyTorchTrialContext",".","It","has","been","separated","into","its","own","object","to","keep","the","size","of","PyTorchTrialContext","down",",","and","because","there","may","be","a","future","where","we","can","create","a","_PyTorchReducerContext","as","a","standalone","feature","for","users","of","the","Core","API","...","though","in","that","case","we","would","rename","it","with","a","public","name","first","."]
code: def run_cross_slot_reduction(
      self, reducables: List[_WrappedReducer], gathered: List[Any]
  ) -> Dict[str, Any]:
      # Reshape list from per-slot-list-of-all-metrics to a per-metric-list-of-all-slots.
      all_per_slot_metrics = zip(*gathered)
  
      metrics = {}
  
      for wrapped, per_slot_metrics in zip(
          reducables, all_per_slot_metrics
      ):
          reduced = wrapped.cross_slot_reduce(per_slot_metrics)
          if wrapped.name is None:
              if not isinstance(reduced, dict):
                  # If wrap_reducer() had name=None, the reduced metric must be a dict.
                  if isinstance(wrapped.reducer, _SimpleReducer):
                      raise AssertionError(
                          f"The custom reduction function {wrapped.reducer.fn.__name__}() was "
                          "wrapped by a call to wrap_reducer() with name=None but it did not "
                          f"return a dict (it returned a {type(reduced).__name__}).  Please set "
                          "name if you wish to return a single metric or return a dictionary "
                          "mapping names to metrics if you with to return multiple metrics from "
                          "a single reducer."
                      )
                  raise AssertionError(
                      f"The custom reduction MetricReducer {type(wrapped.reducer).__name__} was "
                      "wrapped by a call to wrap_reducer() with name=None but it did not return "
                      f"return a dict (it returned a {type(reduced).__name__}).  Please "
                      "set name if you wish to return a single metric or return a dictionary "
                      "mapping names to metrics if you with to return multiple metrics from "
                      "a single reducer."
                  )
              metrics.update(reduced)
          else:
              if isinstance(reduced, dict):
                  # Disallow users from returning dict-like metrics if they provided a name,
                  # because that is just too common of an error.  In the future, if we recursed
                  # into dictionary-type metrics and rendered them in the webui, then this we
                  # could allow this case because it would be trivially easy for users to see
                  # their mistake and fix it.
                  if isinstance(wrapped.reducer, _SimpleReducer):
                      raise AssertionError(
                          f"The custom reduction function {wrapped.reducer.fn.__name__}() was "
                          "wrapped by a call to wrap_reducer() with name set but it returned a "
                          "dict anyway.  Please leave name=None (the default value) if you wish "
                          "to return a dict of multiple metrics or return a single metric (not "
                          "a dict) if you wish to return a single named metric."
                      )
                  raise AssertionError(
                      f"The custom reduction MetricReducer {type(wrapped.reducer).__name__} was "
                      "wrapped by a call to wrap_reducer() with name set but it returned a "
                      "dict anyway.  Please leave name=None (the default value) if you wish "
                      "to return a dict of multiple metrics or return a single metric (not "
                      "a dict) if you wish to return a single named metric."
                  )
              metrics[wrapped.name] = reduced
      return metrics
  
imports: import abc
  import enum
  import itertools
  from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, overload
  import numpy
label_desc: Use image node_id 6 for calling the _PyTorchReducerContext obj's underlying member method code with example usage: obj.run_cross_slot_reduction(reducables, gathered) and returns: metrics