class_docstr: Perceptual loss using features from pretrained deep neural networks trained. The function supports networks
  pretrained on: ImageNet that use the LPIPS approach from Zhang, et al. "The unreasonable effectiveness of deep
  features as a perceptual metric." https://arxiv.org/abs/1801.03924 ; RadImagenet from Mei, et al. "RadImageNet: An
  Open Radiologic Deep Learning Research Dataset for Effective Transfer Learning"
  https://pubs.rsna.org/doi/full/10.1148/ryai.210315 ; MedicalNet from Chen et al. "Med3D: Transfer Learning for
  3D Medical Image Analysis" https://arxiv.org/abs/1904.00625 ;
  and ResNet50 from Torchvision: https://pytorch.org/vision/main/models/generated/torchvision.models.resnet50.html .
  
  The fake 3D implementation is based on a 2.5D approach where we calculate the 2D perceptual loss on slices from all
  three axes and average. The full 3D approach uses a 3D network to calculate the perceptual loss.
  
  Args:
      spatial_dims: number of spatial dimensions.
      network_type: {``"alex"``, ``"vgg"``, ``"squeeze"``, ``"radimagenet_resnet50"``,
      ``"medicalnet_resnet10_23datasets"``, ``"medicalnet_resnet50_23datasets"``, ``"resnet50"``}
          Specifies the network architecture to use. Defaults to ``"alex"``.
      is_fake_3d: if True use 2.5D approach for a 3D perceptual loss.
      fake_3d_ratio: ratio of how many slices per axis are used in the 2.5D approach.
      cache_dir: path to cache directory to save the pretrained network weights.
      pretrained: whether to load pretrained weights. This argument only works when using networks from
          LIPIS or Torchvision. Defaults to ``"True"``.
      pretrained_path: if `pretrained` is `True`, users can specify a weights file to be loaded
          via using this argument. This argument only works when ``"network_type"`` is "resnet50".
          Defaults to `None`.
      pretrained_state_dict_key: if `pretrained_path` is not `None`, this argument is used to
          extract the expected state dict. This argument only works when ``"network_type"`` is "resnet50".
          Defaults to `None`.
docstr: Args:
      input: the shape should be BNHW[D].
      target: the shape should be BNHW[D].
docstr_tok: ["Args",":","input",":","the","shape","should","be","BNHW","[","D","]",".","target",":","the","shape","should","be","BNHW","[","D","]","."]
code: def forward(
      self, input: torch.Tensor, target: torch.Tensor
  ) -> torch.Tensor:
      """
      Args:
          input: the shape should be BNHW[D].
          target: the shape should be BNHW[D].
      """
      if target.shape != input.shape:
          raise ValueError(
              f"ground truth has differing shape ({target.shape}) from input ({input.shape})"
          )
  
      if self.spatial_dims == 3 and self.is_fake_3d:
          # Compute 2.5D approach
          loss_sagittal = self._calculate_axis_loss(
              input, target, spatial_axis=2
          )
          loss_coronal = self._calculate_axis_loss(
              input, target, spatial_axis=3
          )
          loss_axial = self._calculate_axis_loss(
              input, target, spatial_axis=4
          )
          loss = loss_sagittal + loss_axial + loss_coronal
      else:
          # 2D and real 3D cases
          loss = self.perceptual_function(input, target)
  
      return torch.mean(loss)
  
imports: from __future__ import annotations
  import warnings
  import torch
  import torch.nn
  from monai.utils import optional_import
  from monai.utils.enums import StrEnum
label_desc: Use image node_id 3 for calling the PerceptualLoss obj's underlying member method code with example usage: obj.forward(input, target) and returns: torch