class_docstr: Performs pooling (max or mean) on the token embeddings.
  
  Using pooling, it generates from a variable sized sentence a fixed sized sentence embedding. This layer also allows to use the CLS token if it is returned by the underlying word embedding model.
  You can concatenate multiple poolings together.
  
  :param word_embedding_dimension: Dimensions for the word embeddings
  :param pooling_mode: Can be a string: mean/max/cls. If set, overwrites the other pooling_mode_* settings
  :param pooling_mode_cls_token: Use the first token (CLS token) as text representations
  :param pooling_mode_max_tokens: Use max in each dimension over all tokens.
  :param pooling_mode_mean_tokens: Perform mean-pooling
  :param pooling_mode_mean_sqrt_len_tokens: Perform mean-pooling, but divide by sqrt(input_length).
  :param pooling_mode_weightedmean_tokens: Perform (position) weighted mean pooling, see https://arxiv.org/abs/2202.08904
  :param pooling_mode_lasttoken: Perform last token pooling, see https://arxiv.org/abs/2202.08904 & https://arxiv.org/abs/2201.10005
code: def __init__(
      self,
      word_embedding_dimension: int,
      pooling_mode: str = None,
      pooling_mode_cls_token: bool = False,
      pooling_mode_max_tokens: bool = False,
      pooling_mode_mean_tokens: bool = True,
      pooling_mode_mean_sqrt_len_tokens: bool = False,
      pooling_mode_weightedmean_tokens: bool = False,
      pooling_mode_lasttoken: bool = False,
  ):
      super(Pooling, self).__init__()
  
      self.config_keys = [
          "word_embedding_dimension",
          "pooling_mode_cls_token",
          "pooling_mode_mean_tokens",
          "pooling_mode_max_tokens",
          "pooling_mode_mean_sqrt_len_tokens",
          "pooling_mode_weightedmean_tokens",
          "pooling_mode_lasttoken",
      ]
  
      if pooling_mode is not None:  # Set pooling mode by string
          pooling_mode = pooling_mode.lower()
          assert pooling_mode in [
              "mean",
              "max",
              "cls",
              "weightedmean",
              "lasttoken",
          ]
          pooling_mode_cls_token = pooling_mode == "cls"
          pooling_mode_max_tokens = pooling_mode == "max"
          pooling_mode_mean_tokens = pooling_mode == "mean"
          pooling_mode_weightedmean_tokens = (
              pooling_mode == "weightedmean"
          )
          pooling_mode_lasttoken = pooling_mode == "lasttoken"
  
      self.word_embedding_dimension = word_embedding_dimension
      self.pooling_mode_cls_token = pooling_mode_cls_token
      self.pooling_mode_mean_tokens = pooling_mode_mean_tokens
      self.pooling_mode_max_tokens = pooling_mode_max_tokens
      self.pooling_mode_mean_sqrt_len_tokens = (
          pooling_mode_mean_sqrt_len_tokens
      )
      self.pooling_mode_weightedmean_tokens = (
          pooling_mode_weightedmean_tokens
      )
      self.pooling_mode_lasttoken = pooling_mode_lasttoken
  
      pooling_mode_multiplier = sum(
          [
              pooling_mode_cls_token,
              pooling_mode_max_tokens,
              pooling_mode_mean_tokens,
              pooling_mode_mean_sqrt_len_tokens,
              pooling_mode_weightedmean_tokens,
              pooling_mode_lasttoken,
          ]
      )
      self.pooling_output_dimension = (
          pooling_mode_multiplier * word_embedding_dimension
      )
  
file_path: sentence-transformers/sentence_transformers/models/Pooling.py
imports: import torch
  from torch import Tensor
  from torch import nn
  from typing import Dict
  import os
  import json
label_desc: Use image node_id 1 to create a new Pooling object from inherited base classes: nn with example: obj = Pooling(word_embedding_dimension, pooling_mode, pooling_mode_cls_token, pooling_mode_max_tokens, pooling_mode_mean_tokens, pooling_mode_mean_sqrt_len_tokens, pooling_mode_weightedmean_tokens, pooling_mode_lasttoken)