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.
      """
      everything_embedded: bool = True
  
      # if only one sentence is passed, convert to list of sentence
      if type(sentences) is Sentence:
          sentences = [sentences]
  
      for sentence in sentences:
          if self.name not in sentence._embeddings:
              everything_embedded = False
  
      if not everything_embedded:
          self.embeddings.embed(sentences)
  
          for sentence in sentences:
              word_embeddings = []
              for token in sentence.tokens:
                  word_embeddings.append(
                      token.get_embedding().unsqueeze(0)
                  )
  
              word_embeddings = torch.cat(word_embeddings, dim=0).to(
                  flair.device
              )
  
              mean_embedding = torch.mean(word_embeddings, 0)
  
              sentence.set_embedding(self.name, mean_embedding)
  
imports: import logging
  import re
  from pathlib import Path
  from typing import List, Optional, Union
  import torch
  from deprecated.sphinx import deprecated
  import flair
  from flair.data import Sentence, Token
  from flair.embeddings.document import DocumentEmbeddings
  from flair.embeddings.token import StackedEmbeddings, TokenEmbeddings
  from flair.file_utils import cached_path
  from flair.nn import LockedDropout, WordDropout
label_desc: Use image node_id 3 for calling the DocumentMeanEmbeddings obj's underlying member method code with example usage: obj.embed(sentences) without return types