class_docstr: Compute class activation map from the last fully-connected layers before the spatial pooling.
  This implementation is based on:
  
      Zhou et al., Learning Deep Features for Discriminative Localization. CVPR '16,
      https://arxiv.org/abs/1512.04150
  
  Examples
  
  .. code-block:: python
  
      import torch
  
      # densenet 2d
      from monai.networks.nets import DenseNet121
      from monai.visualize import CAM
  
      model_2d = DenseNet121(spatial_dims=2, in_channels=1, out_channels=3)
      cam = CAM(nn_module=model_2d, target_layers="class_layers.relu", fc_layers="class_layers.out")
      result = cam(x=torch.rand((1, 1, 48, 64)))
  
      # resnet 2d
      from monai.networks.nets import seresnet50
      from monai.visualize import CAM
  
      model_2d = seresnet50(spatial_dims=2, in_channels=3, num_classes=4)
      cam = CAM(nn_module=model_2d, target_layers="layer4", fc_layers="last_linear")
      result = cam(x=torch.rand((2, 3, 48, 64)))
  
  N.B.: To help select the target layer, it may be useful to list all layers:
  
  .. code-block:: python
  
      for name, _ in model.named_modules(): print(name)
  
  See Also:
  
      - :py:class:`monai.visualize.class_activation_maps.GradCAM`
docstr: Compute the activation map with upsampling and postprocessing.
  
  Args:
      x: input tensor, shape must be compatible with `nn_module`.
      class_idx: index of the class to be visualized. Default to argmax(logits)
      layer_idx: index of the target layer if there are multiple target layers. Defaults to -1.
      kwargs: any extra arguments to be passed on to the module as part of its `__call__`.
  
  Returns:
      activation maps
code: def __call__(self, x, class_idx=None, layer_idx=-1, **kwargs):
      """
      Compute the activation map with upsampling and postprocessing.
  
      Args:
          x: input tensor, shape must be compatible with `nn_module`.
          class_idx: index of the class to be visualized. Default to argmax(logits)
          layer_idx: index of the target layer if there are multiple target layers. Defaults to -1.
          kwargs: any extra arguments to be passed on to the module as part of its `__call__`.
  
      Returns:
          activation maps
      """
      acti_map = self.compute_map(x, class_idx, layer_idx, **kwargs)
      return self._upsample_and_post_process(acti_map, x)
  
imports: from __future__ import annotations
  import warnings
  from collections.abc import Callable, Sequence
  from typing import cast
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from monai.config import NdarrayTensor
  from monai.transforms import ScaleIntensity
  from monai.utils import ensure_tuple, pytorch_after
  from monai.visualize.visualizer import default_upsampler
label_desc: Use image node_id 3 for calling the CAM obj's underlying member method code with example usage: obj.__call__(x, class_idx, layer_idx) and returns: self