class_docstr: Utility class for the typical cumulative computation process based on PyTorch Tensors.
  It provides interfaces to accumulate values in the local buffers, synchronize buffers across distributed nodes,
  and aggregate the buffered values.
  
  In multi-processing, PyTorch programs usually distribute data to multiple nodes. Each node runs with a subset
  of the data, adds values to its local buffers. Calling `get_buffer` could gather all the results and
  `aggregate` can further handle the results to generate the final outcomes.
  
  Users can implement their own `aggregate` method to handle the results,
  using `get_buffer` to get the buffered contents.
  
  Note: the data list should have the same length every time calling `add()` in a round,
  it will automatically create buffers according to the length of data list.
  
  Typically, this class is expected to execute the following steps:
  
  .. code-block:: python
  
      from monai.metrics import Cumulative
  
      c = Cumulative()
      c.append(1)  # adds a value
      c.extend([2, 3])  # adds a batch of values
      c.extend([4, 5, 6])  # adds a batch of values
      print(c.get_buffer())  # tensor([1, 2, 3, 4, 5, 6])
      print(len(c))  # 6
      c.reset()
      print(len(c))  # 0
  
  The following is an example of maintaining two internal buffers:
  
  .. code-block:: python
  
      from monai.metrics import Cumulative
  
      c = Cumulative()
      c.append(1, 2)  # adds a value to two buffers respectively
      c.extend([3, 4], [5, 6])  # adds batches of values
      print(c.get_buffer())  # [tensor([1, 3, 4]), tensor([2, 5, 6])]
      print(len(c))
  
  The following is an example of extending with variable length data:
  
  .. code-block:: python
  
      import torch
      from monai.metrics import Cumulative
  
      c = Cumulative()
      c.extend(torch.zeros((8, 2)), torch.zeros((6, 2)))  # adds batches
      c.append(torch.zeros((2, )))  # adds a value
      print(c.get_buffer())  # [torch.zeros((9, 2)), torch.zeros((6, 2))]
      print(len(c))
class_docstr_tok: ["Utility","class","for","the","typical","cumulative","computation","process","based","on","PyTorch","Tensors",".","It","provides","interfaces","to","accumulate","values","in","the","local","buffers",",","synchronize","buffers","across","distributed","nodes",",","and","aggregate","the","buffered","values",".","In","multi-processing",",","PyTorch","programs","usually","distribute","data","to","multiple","nodes",".","Each","node","runs","with","a","subset","of","the","data",",","adds","values","to","its","local","buffers",".","Calling","`","get_buffer","`","could","gather","all","the","results","and","`","aggregate","`","can","further","handle","the","results","to","generate","the","final","outcomes",".","Users","can","implement","their","own","`","aggregate","`","method","to","handle","the","results",",","using","`","get_buffer","`","to","get","the","buffered","contents",".","Note",":","the","data","list","should","have","the","same","length","every","time","calling","`","add","(",")","`","in","a","round",",","it","will","automatically","create","buffers","according","to","the","length","of","data","list",".","Typically",",","this","class","is","expected","to","execute","the","following","steps",":","..","code-block",":",":","python","from","monai.metrics","import","Cumulative","c","=","Cumulative","(",")","c.append","(","1",")","#","adds","a","value","c.extend","(","[","2",",","3","]",")","#","adds","a","batch","of","values","c.extend","(","[","4",",","5",",","6","]",")","#","adds","a","batch","of","values","print","(","c.get_buffer","(",")",")","#","tensor","(","[","1",",","2",",","3",",","4",",","5",",","6","]",")","print","(","len","(","c",")",")","#","6","c.reset","(",")","print","(","len","(","c",")",")","#","0","The","following","is","an","example","of","maintaining","two","internal","buffers",":","..","code-block",":",":","python","from","monai.metrics","import","Cumulative","c","=","Cumulative","(",")","c.append","(","1",",","2",")","#","adds","a","value","to","two","buffers","respectively","c.extend","(","[","3",",","4","]",",","[","5",",","6","]",")","#","adds","batches","of","values","print","(","c.get_buffer","(",")",")","#","[","tensor","(","[","1",",","3",",","4","]",")",",","tensor","(","[","2",",","5",",","6","]",")","]","print","(","len","(","c",")",")","The","following","is","an","example","of","extending","with","variable","length","data",":","..","code-block",":",":","python","import","torch","from","monai.metrics","import","Cumulative","c","=","Cumulative","(",")","c.extend","(","torch.zeros","(","(","8",",","2",")",")",",","torch.zeros","(","(","6",",","2",")",")",")","#","adds","batches","c.append","(","torch.zeros","(","(","2",",",")",")",")","#","adds","a","value","print","(","c.get_buffer","(",")",")","#","[","torch.zeros","(","(","9",",","2",")",")",",","torch.zeros","(","(","6",",","2",")",")","]","print","(","len","(","c",")",")"]
docstr: Get the synchronized list of buffers.
  A typical usage is to generate the metrics report based on the raw metric details.
  Each buffer is a PyTorch Tensor.
docstr_tok: ["Get","the","synchronized","list","of","buffers",".","A","typical","usage","is","to","generate","the","metrics","report","based","on","the","raw","metric","details",".","Each","buffer","is","a","PyTorch","Tensor","."]
code: def get_buffer(self):
      """
      Get the synchronized list of buffers.
      A typical usage is to generate the metrics report based on the raw metric details.
      Each buffer is a PyTorch Tensor.
  
      """
      self._sync()
      if self._synced_tensors is None:
          return self._synced_tensors
      buffers = [
          x.detach().clone() if isinstance(x, torch.Tensor) else x
          for x in self._synced_tensors
      ]
      return buffers[0] if len(buffers) == 1 else buffers
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from collections.abc import Sequence
  from typing import Any
  import torch
  from monai.config import TensorOrList
  from monai.utils import convert_data_type, evenly_divisible_all_gather
label_desc: Use image node_id 8 for calling the Cumulative obj's underlying member method code with example usage: obj.get_buffer() and returns: unknown, self