class_docstr: A base class for merging patches.
  Extend this class to support operations for `PatchInference`.
  There are two methods that must be implemented in the concrete classes:
  
      - aggregate: aggregate the values at their corresponding locations
      - finalize: perform any final process and return the merged output
  
  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 where Merger tensors should reside.
docstr: Aggregate values for merging.
  This method is being called in a loop and should add values to their corresponding location in the merged output results.
  
  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 output.
  
  Raises:
      NotImplementedError: When the subclass does not override this method.
docstr_tok: ["Aggregate","values","for","merging",".","This","method","is","being","called","in","a","loop","and","should","add","values","to","their","corresponding","location","in","the","merged","output","results",".","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","output",".","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.
      This method is being called in a loop and should add values to their corresponding location in the merged output results.
  
      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 output.
  
      Raises:
          NotImplementedError: When the subclass does not override this method.
  
      """
      raise NotImplementedError(
          f"Subclass {self.__class__.__name__} must implement this method."
      )
  
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 Merger obj's underlying member method code with example usage: obj.aggregate(values, location) without return types