class_docstr: Trainer extension to aggregate an observation in the trainer.
  Args:
       comm: ChainerMN communicator
       original_key (str): Key of the observation to be summarized.
       If the observation is a :class:`chainer.Variable`, its value
       is automatically copied to CPU.
       aggregated_key (str): Name of the key after the summarization.
       If not specified, it is set to `original_key` to overwrite it.
       comm_trigger: Trigger that decides the timing to communicate
       observation values for aggregation.
       aggregator (function): Function to compute summarization from
       individual values. It takes a list of lists of observed values.
       Each list contains all the observed values since
       the last communication.
code: def compute_summary(self, trainer):
      if self.original_key in trainer.observation:
          value = trainer.observation[self.original_key]
          if isinstance(value, Variable):
              # use to native device as ChainerX array cannot
              # be converted to numpy directly, which is what `to_cpu()` does
              value.to_device("native")
          elif isinstance(
              value, chx.ndarray
          ) and not value.device.name.startswith("native"):
              raise ValueError(
                  "observation aggregator does not support "
                  "ChainerX ndarray on CUDA device."
              )
          self.observation_history.append(value)
  
      if not self.comm_trigger(trainer):
          return None
  
      observation_history_gathered = self.comm.gather_obj(
          self.observation_history
      )
      self.observation_history = []
  
      if self.comm.rank == 0:
          global_summary = self.aggregator(observation_history_gathered)
          self.comm.bcast_obj(global_summary)
      else:
          global_summary = self.comm.bcast_obj(None)
  
      return global_summary
  
file_path: chainer/chainermn/extensions/observation_aggregator.py
imports: from __future__ import division
  from chainer.training import extension, util
  from chainer import Variable
  import chainerx
label_desc: Use image node_id 2 for calling the ObservationAggregator obj's underlying member method code with example usage: obj.compute_summary(trainer) and returns: global_summary, None