docstr: Add embeddings to every sentence in the given list of sentences.
  
  If embeddings are already added, updates only if embeddings are non-static.
docstr_tok: ["Add","embeddings","to","every","sentence","in","the","given","list","of","sentences",".","If","embeddings","are","already","added",",","updates","only","if","embeddings","are","non-static","."]
code: def embed(self, sentences: Union[List[Sentence], Sentence]):
      """Add embeddings to every sentence in the given list of sentences.
  
      If embeddings are already added, updates only if embeddings are non-static.
      """
      # if only one sentence is passed, convert to list of sentence
      if isinstance(sentences, Sentence):
          sentences = [sentences]
  
      self.embeddings.embed(sentences)
  
      for sentence in sentences:
          word_embeddings = torch.cat(
              [
                  token.get_embedding().unsqueeze(0)
                  for token in sentence.tokens
              ],
              dim=0,
          ).to(flair.device)
  
          if self.fine_tune_mode in ["nonlinear", "linear"]:
              word_embeddings = self.embedding_flex(word_embeddings)
  
          if self.fine_tune_mode in ["nonlinear"]:
              word_embeddings = self.embedding_flex_nonlinear(
                  word_embeddings
              )
              word_embeddings = self.embedding_flex_nonlinear_map(
                  word_embeddings
              )
  
          if self.pooling == "mean":
              pooled_embedding = torch.mean(word_embeddings, 0)
          elif self.pooling == "max":
              pooled_embedding, _ = torch.max(word_embeddings, 0)
          elif self.pooling == "min":
              pooled_embedding, _ = torch.min(word_embeddings, 0)
  
          sentence.set_embedding(self.name, pooled_embedding)
  
imports: import logging
  from typing import Any, Dict, List, Optional, Union, cast
  import torch
  from sklearn.feature_extraction.text import TfidfVectorizer
  from torch.nn import RNNBase
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
  import flair
  from flair.data import Sentence
  from flair.embeddings.base import DocumentEmbeddings, load_embeddings, register_embeddings
  from flair.embeddings.token import FlairEmbeddings, StackedEmbeddings, TokenEmbeddings
  from flair.embeddings.transformer import TransformerEmbeddings, TransformerOnnxDocumentEmbeddings
  from flair.nn import LockedDropout, WordDropout
label_desc: Use image node_id 3 for calling the DocumentPoolEmbeddings obj's underlying member method code with example usage: obj.embed(sentences) without return types