class_docstr: Wrap a user-provided reduction function in a MetricReducer API.  It is not as efficient as the
  full MetricReducer API but simpler for users.
class_docstr_tok: ["Wrap","a","user-provided","reduction","function","in","a","MetricReducer","API",".","It","is","not","as","efficient","as","the","full","MetricReducer","API","but","simpler","for","users","."]
docstr: Call the reducer function on metrics in their original order.
  
  Interleave metrics from different slots as we flatten
  the list of metrics to undo the effect of sharding.
  Note: this will only reconstruct the original order if the user
  calls ``update()`` once per batch
docstr_tok: ["Call","the","reducer","function","on","metrics","in","their","original","order",".","Interleave","metrics","from","different","slots","as","we","flatten","the","list","of","metrics","to","undo","the","effect","of","sharding",".","Note",":","this","will","only","reconstruct","the","original","order","if","the","user","calls","``","update","(",")","``","once","per","batch"]
code: def cross_slot_reduce(self, per_slot_metrics: List) -> Any:
      """
      Call the reducer function on metrics in their original order.
  
      Interleave metrics from different slots as we flatten
      the list of metrics to undo the effect of sharding.
      Note: this will only reconstruct the original order if the user
      calls ``update()`` once per batch
      """
      interleaved = itertools.zip_longest(
          *per_slot_metrics, fillvalue=_SimpleReducer.NOT_METRIC
      )
      flat_metrics = [
          m
          for sublist in interleaved
          for m in sublist
          if m is not _SimpleReducer.NOT_METRIC
      ]
  
      return self.fn(flat_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 5 for calling the _SimpleReducer obj's underlying member method code with example usage: obj.cross_slot_reduce(per_slot_metrics) and returns: self