class_docstr: Wrapper to replace the last layer of model by convolutional layer or FC layer.
  
  See also: :py:class:`monai.networks.nets.TorchVisionFCModel`
  
  Args:
      model: a PyTorch model, which can be both 2D and 3D models. typically, it can be a pretrained model
          in Torchvision, like: ``resnet18``, ``resnet34``, ``resnet50``, ``resnet101``, ``resnet152``, etc.
          more details: https://pytorch.org/vision/stable/models.html.
      num_classes: number of classes for the last classification layer. Default to 1.
      dim: number of supported spatial dimensions in the specified model, depends on the model implementation.
          default to 2 as most Torchvision models are for 2D image processing.
      in_channels: number of the input channels of last layer. if None, get it from `in_features` of last layer.
      use_conv: whether to use convolutional layer to replace the last layer, default to False.
      pool: parameters for the pooling layer, it should be a tuple, the first item is name of the pooling layer,
          the second item is dictionary of the initialization args. if None, will not replace the `layers[-2]`.
          default to `("avg", {"kernel_size": 7, "stride": 1})`.
      bias: the bias value when replacing the last layer. if False, the layer will not learn an additive bias,
          default to True.
      fc_name: the corresponding layer attribute of the last fully connected layer. Defaults to ``"fc"``.
      node_name: the corresponding feature extractor node name of `model`.
          Defaults to "", the extractor is not in use.
code: def forward(self, x):
      x = self.features(x)
      if isinstance(x, tuple):
          x = x[
              0
          ]  # it might be a namedtuple such as torchvision.model.InceptionOutputs
      elif torch.jit.isinstance(x, Dict[str, torch.Tensor]):
          x = x[self.node_name]  # torchvision create_feature_extractor
      if self.pool is not None:
          x = self.pool(x)
      if not self.use_conv:
          x = torch.flatten(x, 1)
      else:  # user specified `use_conv` but the pooling layer removed the spatial dims
          while len(x.shape) < self.dim + 2:
              x = x[..., None]
      x = self.fc(x)
  
      return x
  
file_path: MONAI/monai/networks/nets/netadapter.py
imports: from __future__ import annotations
  from typing import Any, Dict
  import torch
  from monai.networks.layers import Conv, get_pool_layer
  from monai.networks.utils import look_up_named_module, set_named_module
  from monai.utils import look_up_option, optional_import
label_desc: Use image node_id 2 for calling the NetAdapter obj's underlying member method code with example usage: obj.forward(x) and returns: x