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.
code: def __init__(
      self,
      merged_shape: Sequence[int],
      cropped_shape: Sequence[int] | None = None,
      device: torch.device | str | None = None,
  ) -> None:
      self.merged_shape = merged_shape
      self.cropped_shape = (
          self.merged_shape if cropped_shape is None else cropped_shape
      )
      self.device = device
      self.is_finalized = False
  
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 1 to create a new Merger object from inherited base classes: ABC with example: obj = Merger(merged_shape, cropped_shape, device)