class_docstr: Dialogue Nearest Neighbour Model identifies the intent of an utterance using the cosine similarity between sentence embeddings of the utterance and various label descriptions 
class_docstr_tok: ["Dialogue","Nearest","Neighbour","Model","identifies","the","intent","of","an","utterance","using","the","cosine","similarity","between","sentence","embeddings","of","the","utterance","and","various","label","descriptions"]
code: def mean_pooling(model_output, attention_mask):
      token_embeddings = model_output[
          0
      ]  # First element of model_output contains all token embeddings
      input_mask_expanded = (
          attention_mask.unsqueeze(-1)
          .expand(token_embeddings.size())
          .float()
      )
      return torch.sum(
          token_embeddings * input_mask_expanded, 1
      ) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
  
imports: import os
  from typing import Optional
  import numpy
  import torch
  import torch.nn.functional
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from transformers import AutoModel
  from nemo.collections.nlp.data.dialogue import DialogueSGDDataProcessor
  from nemo.collections.nlp.data.dialogue.data_processor.assistant_data_processor import DialogueAssistantDataProcessor
  from nemo.collections.nlp.data.dialogue.data_processor.design_data_processor import DialogueDesignDataProcessor
  from nemo.collections.nlp.data.dialogue.dataset.dialogue_nearest_neighbour_dataset import DialogueNearestNeighbourDataset
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.metrics.dialogue_metrics import DialogueGenerationMetrics
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
label_desc: Use image node_id 6 for calling the DialogueNearestNeighbourModel obj's underlying member method code with example usage: obj.mean_pooling(model_output, attention_mask) and returns: unknown