class_docstr: Patchcore Module.
class_docstr_tok: ["Patchcore","Module","."]
docstr: Generate embedding from hierarchical feature map.
  
  Args:
      features: Hierarchical feature map from a CNN (ResNet18 or WideResnet)
      features: dict[str:Tensor]:
  
  Returns:
      Embedding vector
docstr_tok: ["Generate","embedding","from","hierarchical","feature","map",".","Args",":","features",":","Hierarchical","feature","map","from","a","CNN","(","ResNet18","or","WideResnet",")","features",":","dict","[","str",":","Tensor","]",":","Returns",":","Embedding","vector"]
code: def generate_embedding(self, features: dict[str, Tensor]) -> Tensor:
      """Generate embedding from hierarchical feature map.
  
      Args:
          features: Hierarchical feature map from a CNN (ResNet18 or WideResnet)
          features: dict[str:Tensor]:
  
      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="bilinear",
          )
          embeddings = torch.cat((embeddings, layer_embedding), 1)
  
      return embeddings
  
file_path: anomalib/src/anomalib/models/patchcore/torch_model.py
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from anomalib.models.components import DynamicBufferModule, FeatureExtractor, KCenterGreedy
  from anomalib.models.patchcore.anomaly_map import AnomalyMapGenerator
  from anomalib.pre_processing import Tiler
label_desc: Use image node_id 3 for calling the PatchcoreModel obj's underlying member method code with example usage: obj.generate_embedding(features) and returns: embeddings