class_docstr: Merge patches by taking average of the overlapping area
  
  Args:
      merged_shape: the shape of the tensor required to merge the patches.
      cropped_shape: the shape of the final merged output tensor.
          If not provided, it will be the same as `merged_shape`.
      device: the device for aggregator tensors and final results.
      value_dtype: the dtype for value aggregating tensor and the final result.
      count_dtype: the dtype for sample counting tensor.
docstr: Aggregate values for merging.
  
  Args:
      values: a tensor of shape BCHW[D], representing the values of inference output.
      location: a tuple/list giving the top left location of the patch in the original image.
  
  Raises:
      NotImplementedError: When the subclass does not override this method.
docstr_tok: ["Aggregate","values","for","merging",".","Args",":","values",":","a","tensor","of","shape","BCHW","[","D","]",",","representing","the","values","of","inference","output",".","location",":","a","tuple\/list","giving","the","top","left","location","of","the","patch","in","the","original","image",".","Raises",":","NotImplementedError",":","When","the","subclass","does","not","override","this","method","."]
code: def aggregate(
      self, values: torch.Tensor, location: Sequence[int]
  ) -> None:
      """
      Aggregate values for merging.
  
      Args:
          values: a tensor of shape BCHW[D], representing the values of inference output.
          location: a tuple/list giving the top left location of the patch in the original image.
  
      Raises:
          NotImplementedError: When the subclass does not override this method.
  
      """
      if self.is_finalized:
          raise ValueError(
              "`AvgMerger` is already finalized. Please instantiate a new object to aggregate."
          )
      patch_size = values.shape[2:]
      map_slice = tuple(
          slice(loc, loc + size)
          for loc, size in zip(location, patch_size)
      )
      map_slice = ensure_tuple_size(
          map_slice,
          values.ndim,
          pad_val=slice(None),
          pad_from_start=True,
      )
      self.values[map_slice] += values
      self.counts[map_slice] += 1
  
imports: from __future__ import annotations
  import threading
  from abc import ABC, abstractmethod
  from collections.abc import Sequence
  from contextlib import nullcontext
  from typing import TYPE_CHECKING, Any
  import numpy
  import torch
  from monai.utils import ensure_tuple_size, optional_import, require_pkg
label_desc: Use image node_id 2 for calling the AvgMerger obj's underlying member method code with example usage: obj.aggregate(values, location) without return types