class_docstr: Generate Anomaly Heatmap.
docstr: Compute the layer map based on cosine similarity.
  
  Args:
    teacher_features (Tensor): Teacher features
    student_features (Tensor): Student features
  
  Returns:
    Anomaly score based on cosine similarity.
docstr_tok: ["Compute","the","layer","map","based","on","cosine","similarity",".","Args",":","teacher_features","(","Tensor",")",":","Teacher","features","student_features","(","Tensor",")",":","Student","features","Returns",":","Anomaly","score","based","on","cosine","similarity","."]
code: def compute_layer_map(
      self, teacher_features: Tensor, student_features: Tensor
  ) -> Tensor:
      """Compute the layer map based on cosine similarity.
  
      Args:
        teacher_features (Tensor): Teacher features
        student_features (Tensor): Student features
  
      Returns:
        Anomaly score based on cosine similarity.
      """
      norm_teacher_features = F.normalize(teacher_features)
      norm_student_features = F.normalize(student_features)
  
      layer_map = (
          0.5
          * torch.norm(
              norm_teacher_features - norm_student_features,
              p=2,
              dim=-3,
              keepdim=True,
          )
          ** 2
      )
      layer_map = F.interpolate(
          layer_map,
          size=self.image_size,
          align_corners=False,
          mode="bilinear",
      )
      return layer_map
  
file_path: anomalib/src/anomalib/models/stfpm/anomaly_map.py
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from omegaconf import ListConfig
  from torch import Tensor, nn
label_desc: Use image node_id 2 for calling the AnomalyMapGenerator obj's underlying member method code with example usage: obj.compute_layer_map(teacher_features, student_features) and returns: layer_map