docstr: Bidirectional transformer embeddings of words from various transformer architectures.
  
  Args:
      model: name of transformer model (see https://huggingface.co/transformers/pretrained_models.html for options)
      layers: string indicating which layers to take for embedding (-1 is topmost layer)
      cls_pooling: Pooling strategy for combining token level embeddings. options are 'cls', 'max', 'mean'.
      layer_mean: If True, uses a scalar mix of layers as embedding
      fine_tune: If True, allows transformers to be fine-tuned during training
      is_token_embedding: If True, the embedding can be used as TokenEmbedding too.
      **kwargs: Arguments propagated to :meth:`flair.embeddings.transformer.TransformerEmbeddings.__init__`
docstr_tok: ["Bidirectional","transformer","embeddings","of","words","from","various","transformer","architectures",".","Args",":","model",":","name","of","transformer","model","(","see","https",":","\/\/huggingface.co\/transformers\/pretrained_models.html","for","options",")","layers",":","string","indicating","which","layers","to","take","for","embedding","(","-1","is","topmost","layer",")","cls_pooling",":","Pooling","strategy","for","combining","token","level","embeddings",".","options","are","'cls","'",",","'max","'",",","'mean","'",".","layer_mean",":","If","True",",","uses","a","scalar","mix","of","layers","as","embedding","fine_tune",":","If","True",",","allows","transformers","to","be","fine-tuned","during","training","is_token_embedding",":","If","True",",","the","embedding","can","be","used","as","TokenEmbedding","too",".","*","*","kwargs",":","Arguments","propagated","to",":","meth",":","`","flair.embeddings.transformer.TransformerEmbeddings.__init__","`"]
code: def __init__(
      self,
      model: str = "bert-base-uncased",  # set parameters with different default values
      layers: str = "-1",
      layer_mean: bool = False,
      is_token_embedding: bool = False,
      **kwargs,
  ) -> None:
      """Bidirectional transformer embeddings of words from various transformer architectures.
  
      Args:
          model: name of transformer model (see https://huggingface.co/transformers/pretrained_models.html for options)
          layers: string indicating which layers to take for embedding (-1 is topmost layer)
          cls_pooling: Pooling strategy for combining token level embeddings. options are 'cls', 'max', 'mean'.
          layer_mean: If True, uses a scalar mix of layers as embedding
          fine_tune: If True, allows transformers to be fine-tuned during training
          is_token_embedding: If True, the embedding can be used as TokenEmbedding too.
          **kwargs: Arguments propagated to :meth:`flair.embeddings.transformer.TransformerEmbeddings.__init__`
      """
      TransformerEmbeddings.__init__(
          self,
          model=model,
          layers=layers,
          layer_mean=layer_mean,
          is_token_embedding=is_token_embedding,
          is_document_embedding=True,
          **kwargs,
      )
  
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 1 to create a new TransformerDocumentEmbeddings object from inherited base classes: DocumentEmbeddings, TransformerEmbeddings with example: obj = TransformerDocumentEmbeddings(model, layers, layer_mean, is_token_embedding)