class_docstr: Huggingface AutoModel to generate token embeddings.
  Loads the correct class, e.g. BERT / RoBERTa etc.
  
  :param model_name_or_path: Huggingface models name (https://huggingface.co/models)
  :param max_seq_length: Truncate any inputs longer than max_seq_length
  :param model_args: Arguments (key, value pairs) passed to the Huggingface Transformers model
  :param cache_dir: Cache dir for Huggingface Transformers to store/load models
  :param tokenizer_args: Arguments (key, value pairs) passed to the Huggingface Tokenizer model
  :param do_lower_case: If true, lowercases the input (independent if the model is cased or not)
  :param tokenizer_name_or_path: Name or path of the tokenizer. When None, then model_name_or_path is used
class_docstr_tok: ["Huggingface","AutoModel","to","generate","token","embeddings",".","Loads","the","correct","class",",","e.g",".","BERT","\/","RoBERTa","etc",".",":","param","model_name_or_path",":","Huggingface","models","name","(","https",":","\/\/huggingface.co\/models",")",":","param","max_seq_length",":","Truncate","any","inputs","longer","than","max_seq_length",":","param","model_args",":","Arguments","(","key",",","value","pairs",")","passed","to","the","Huggingface","Transformers","model",":","param","cache_dir",":","Cache","dir","for","Huggingface","Transformers","to","store\/load","models",":","param","tokenizer_args",":","Arguments","(","key",",","value","pairs",")","passed","to","the","Huggingface","Tokenizer","model",":","param","do_lower_case",":","If","true",",","lowercases","the","input","(","independent","if","the","model","is","cased","or","not",")",":","param","tokenizer_name_or_path",":","Name","or","path","of","the","tokenizer",".","When","None",",","then","model_name_or_path","is","used"]
code: def __init__(
      self,
      model_name_or_path: str,
      max_seq_length: Optional[int] = None,
      model_args: Dict = {},
      cache_dir: Optional[str] = None,
      tokenizer_args: Dict = {},
      do_lower_case: bool = False,
      tokenizer_name_or_path: str = None,
  ):
      super(Transformer, self).__init__()
      self.config_keys = ["max_seq_length", "do_lower_case"]
      self.do_lower_case = do_lower_case
  
      config = AutoConfig.from_pretrained(
          model_name_or_path, **model_args, cache_dir=cache_dir
      )
      self._load_model(
          model_name_or_path, config, cache_dir, **model_args
      )
  
      self.tokenizer = AutoTokenizer.from_pretrained(
          tokenizer_name_or_path
          if tokenizer_name_or_path is not None
          else model_name_or_path,
          cache_dir=cache_dir,
          **tokenizer_args,
      )
  
      # No max_seq_length set. Try to infer from model
      if max_seq_length is None:
          if (
              hasattr(self.auto_model, "config")
              and hasattr(
                  self.auto_model.config, "max_position_embeddings"
              )
              and hasattr(self.tokenizer, "model_max_length")
          ):
              max_seq_length = min(
                  self.auto_model.config.max_position_embeddings,
                  self.tokenizer.model_max_length,
              )
  
      self.max_seq_length = max_seq_length
  
      if tokenizer_name_or_path is not None:
          self.auto_model.config.tokenizer_class = (
              self.tokenizer.__class__.__name__
          )
  
file_path: sentence-transformers/sentence_transformers/models/Transformer.py
imports: from torch import nn
  from transformers import AutoModel, AutoTokenizer, AutoConfig, T5Config, MT5Config
  import json
  from typing import List, Dict, Optional, Union, Tuple
  import os
label_desc: Use image node_id 1 to create a new Transformer object from inherited base classes: nn with example: obj = Transformer(model_name_or_path, max_seq_length, model_args, cache_dir, tokenizer_args, do_lower_case, tokenizer_name_or_path)