class_docstr: SliceInferer extends SlidingWindowInferer to provide slice-by-slice (2D) inference when provided a 3D volume.
  A typical use case could be a 2D model (like 2D segmentation UNet) operates on the slices from a 3D volume,
  and the output is a 3D volume with 2D slices aggregated. Example::
  
      # sliding over the `spatial_dim`
      inferer = SliceInferer(roi_size=(64, 256), sw_batch_size=1, spatial_dim=1)
      output = inferer(input_volume, net)
  
  Args:
      spatial_dim: Spatial dimension over which the slice-by-slice inference runs on the 3D volume.
          For example ``0`` could slide over axial slices. ``1`` over coronal slices and ``2`` over sagittal slices.
      args: other optional args to be passed to the `__init__` of base class SlidingWindowInferer.
      kwargs: other optional keyword args to be passed to `__init__` of base class SlidingWindowInferer.
  
  Note:
      ``roi_size`` in SliceInferer is expected to be a 2D tuple when a 3D volume is provided. This allows
      sliding across slices along the 3D volume using a selected ``spatial_dim``.
class_docstr_tok: ["SliceInferer","extends","SlidingWindowInferer","to","provide","slice-by-slice","(","2D",")","inference","when","provided","a","3D","volume",".","A","typical","use","case","could","be","a","2D","model","(","like","2D","segmentation","UNet",")","operates","on","the","slices","from","a","3D","volume",",","and","the","output","is","a","3D","volume","with","2D","slices","aggregated",".","Example",":",":","#","sliding","over","the","`","spatial_dim","`","inferer","=","SliceInferer","(","roi_size=","(","64",",","256",")",",","sw_batch_size=1",",","spatial_dim=1",")","output","=","inferer","(","input_volume",",","net",")","Args",":","spatial_dim",":","Spatial","dimension","over","which","the","slice-by-slice","inference","runs","on","the","3D","volume",".","For","example","``","0","``","could","slide","over","axial","slices",".","``","1","``","over","coronal","slices","and","``","2","``","over","sagittal","slices",".","args",":","other","optional","args","to","be","passed","to","the","`","__init__","`","of","base","class","SlidingWindowInferer",".","kwargs",":","other","optional","keyword","args","to","be","passed","to","`","__init__","`","of","base","class","SlidingWindowInferer",".","Note",":","``","roi_size","``","in","SliceInferer","is","expected","to","be","a","2D","tuple","when","a","3D","volume","is","provided",".","This","allows","sliding","across","slices","along","the","3D","volume","using","a","selected","``","spatial_dim","``","."]
docstr: Args:
      inputs: 3D input for inference
      network: 2D model to execute inference on slices in the 3D input
      args: optional args to be passed to ``network``.
      kwargs: optional keyword args to be passed to ``network``.
docstr_tok: ["Args",":","inputs",":","3D","input","for","inference","network",":","2D","model","to","execute","inference","on","slices","in","the","3D","input","args",":","optional","args","to","be","passed","to","``","network","``",".","kwargs",":","optional","keyword","args","to","be","passed","to","``","network","``","."]
code: def __call__(
      self,
      inputs: torch.Tensor,
      network: Callable[
          ...,
          torch.Tensor
          | Sequence[torch.Tensor]
          | dict[Any, torch.Tensor],
      ],
      *args: Any,
      **kwargs: Any,
  ) -> (
      torch.Tensor | tuple[torch.Tensor, ...] | dict[Any, torch.Tensor]
  ):
      """
      Args:
          inputs: 3D input for inference
          network: 2D model to execute inference on slices in the 3D input
          args: optional args to be passed to ``network``.
          kwargs: optional keyword args to be passed to ``network``.
      """
      if self.spatial_dim > 2:
          raise ValueError(
              "`spatial_dim` can only be `0, 1, 2` with `[H, W, D]` respectively."
          )
  
      # Check if ``roi_size`` tuple is 2D and ``inputs`` tensor is 3D
      self.roi_size = ensure_tuple(self.roi_size)
      if len(self.orig_roi_size) == 2 and len(inputs.shape[2:]) == 3:
          self.roi_size = list(self.orig_roi_size)
          self.roi_size.insert(self.spatial_dim, 1)
      else:
          raise RuntimeError(
              f"Currently, only 2D `roi_size` ({self.orig_roi_size}) with 3D `inputs` tensor (shape={inputs.shape}) is supported."
          )
  
      return super().__call__(
          inputs=inputs,
          network=lambda x: self.network_wrapper(
              network, x, *args, **kwargs
          ),
      )
  
imports: from __future__ import annotations
  import warnings
  from abc import ABC, abstractmethod
  from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
  from pydoc import locate
  from typing import Any
  import torch
  import torch.nn
  from monai.apps.utils import get_logger
  from monai.data.meta_tensor import MetaTensor
  from monai.data.thread_buffer import ThreadBuffer
  from monai.inferers.merger import AvgMerger, Merger
  from monai.inferers.splitter import Splitter
  from monai.inferers.utils import compute_importance_map, sliding_window_inference
  from monai.utils import BlendMode, PatchKeys, PytorchPadMode, ensure_tuple, optional_import
  from monai.visualize import CAM, GradCAM, GradCAMpp
label_desc: Use image node_id 2 for calling the SliceInferer obj's underlying member method code with example usage: obj.__call__(inputs, network) and returns: super