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",")","."]
docstr: Generate embedding from hierarchical feature map.
  
  Args:
      features (dict[str, Tensor]): Hierarchical feature map from a CNN (ResNet18 or WideResnet)
  
  Returns:
      Embedding vector
docstr_tok: ["Generate","embedding","from","hierarchical","feature","map",".","Args",":","features","(","dict","[","str",",","Tensor","]",")",":","Hierarchical","feature","map","from","a","CNN","(","ResNet18","or","WideResnet",")","Returns",":","Embedding","vector"]
code: def generate_embedding(self, features: dict[str, Tensor]) -> Tensor:
      """Generate embedding from hierarchical feature map.
  
      Args:
          features (dict[str, Tensor]): Hierarchical feature map from a CNN (ResNet18 or WideResnet)
  
      Returns:
          Embedding vector
      """
  
      embeddings = features[self.layers[0]]
      for layer in self.layers[1:]:
          layer_embedding = features[layer]
          layer_embedding = F.interpolate(
              layer_embedding,
              size=embeddings.shape[-2:],
              mode="nearest",
          )
          embeddings = torch.cat((embeddings, layer_embedding), 1)
  
      # subsample embeddings
      idx = self.idx.to(embeddings.device)
      embeddings = torch.index_select(embeddings, 1, idx)
      return embeddings
  
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 3 for calling the PadimModel obj's underlying member method code with example usage: obj.generate_embedding(features) and returns: embeddings