class_docstr: Padim Module.
  
  Args:
      input_size (tuple[int, int]): Input size for the model.
      layers (list[str]): Layers used for feature extraction
      backbone (str, optional): Pre-trained model backbone. Defaults to "resnet18".
      pre_trained (bool, optional): Boolean to check whether to use a pre_trained backbone.
      n_features (int, optional): Number of features to retain in the dimension reduction step.
                              Default values from the paper are available for: resnet18 (100), wide_resnet50_2 (550).
class_docstr_tok: ["Padim","Module",".","Args",":","input_size","(","tuple","[","int",",","int","]",")",":","Input","size","for","the","model",".","layers","(","list","[","str","]",")",":","Layers","used","for","feature","extraction","backbone","(","str",",","optional",")",":","Pre-trained","model","backbone",".","Defaults","to","``","resnet18","''",".","pre_trained","(","bool",",","optional",")",":","Boolean","to","check","whether","to","use","a","pre_trained","backbone",".","n_features","(","int",",","optional",")",":","Number","of","features","to","retain","in","the","dimension","reduction","step",".","Default","values","from","the","paper","are","available","for",":","resnet18","(","100",")",",","wide_resnet50_2","(","550",")","."]
code: def __init__(
      self,
      input_size: tuple[int, int],
      layers: list[str],
      backbone: str = "resnet18",
      pre_trained: bool = True,
      n_features: int | None = None,
  ) -> None:
      super().__init__()
      self.tiler: Tiler | None = None
  
      self.backbone = backbone
      self.layers = layers
      self.feature_extractor = FeatureExtractor(
          backbone=self.backbone, layers=layers, pre_trained=pre_trained
      )
      self.n_features_original, self.n_patches = _deduce_dims(
          self.feature_extractor, input_size, self.layers
      )
  
      n_features = n_features or _N_FEATURES_DEFAULTS.get(self.backbone)
  
      if n_features is None:
          raise ValueError(
              f"n_features must be specified for backbone {self.backbone}. "
              f"Default values are available for: {sorted(_N_FEATURES_DEFAULTS.keys())}"
          )
  
      assert (
          0 < n_features <= self.n_features_original
      ), f"for backbone {self.backbone}, 0 < n_features <= {self.n_features_original}, found {n_features}"
  
      self.n_features = n_features
  
      # pylint: disable=not-callable
      # Since idx is randomly selected, save it with model to get same results
      self.register_buffer(
          "idx",
          torch.tensor(
              sample(
                  range(0, self.n_features_original), self.n_features
              )
          ),
      )
      self.idx: Tensor
      self.loss = None
      self.anomaly_map_generator = AnomalyMapGenerator(
          image_size=input_size
      )
  
      self.gaussian = MultiVariateGaussian(
          self.n_features, self.n_patches
      )
  
file_path: anomalib/src/anomalib/models/padim/torch_model.py
imports: from __future__ import annotations
  from random import sample
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from anomalib.models.components import FeatureExtractor, MultiVariateGaussian
  from anomalib.models.components.feature_extractors import dryrun_find_featuremap_dims
  from anomalib.models.padim.anomaly_map import AnomalyMapGenerator
  from anomalib.pre_processing import Tiler
label_desc: Use image node_id 1 to create a new PadimModel object from inherited base classes: nn with example: obj = PadimModel(input_size, layers, backbone, pre_trained, n_features)