class_docstr: A combination of a tokenizer and a model.
class_docstr_tok: ["A","combination","of","a","tokenizer","and","a","model","."]
docstr: Initialize the encoder using :class:`transformers.AutoModel`.
  
  :param pretrained_model_name_or_path:
      the name of the pretrained model, or a path, cf. :meth:`transformers.AutoModel.from_pretrained`
  :param max_length: >0, default: 512
      the maximum number of tokens to pad/trim the labels to
  
  :raises ImportError:
      if the :mod:`transformers` library could not be imported
docstr_tok: ["Initialize","the","encoder","using",":","class",":","`","transformers.AutoModel","`",".",":","param","pretrained_model_name_or_path",":","the","name","of","the","pretrained","model",",","or","a","path",",","cf",".",":","meth",":","`","transformers.AutoModel.from_pretrained","`",":","param","max_length",":",">","0",",","default",":","512","the","maximum","number","of","tokens","to","pad\/trim","the","labels","to",":","raises","ImportError",":","if","the",":","mod",":","`","transformers","`","library","could","not","be","imported"]
code: def __init__(
      self,
      pretrained_model_name_or_path: str = "bert-base-cased",
      max_length: int = 512,
  ):
      """
      Initialize the encoder using :class:`transformers.AutoModel`.
  
      :param pretrained_model_name_or_path:
          the name of the pretrained model, or a path, cf. :meth:`transformers.AutoModel.from_pretrained`
      :param max_length: >0, default: 512
          the maximum number of tokens to pad/trim the labels to
  
      :raises ImportError:
          if the :mod:`transformers` library could not be imported
      """
      super().__init__()
      try:
          from transformers import (
              AutoModel,
              AutoTokenizer,
              PreTrainedTokenizer,
          )
      except ImportError as error:
          raise ImportError(
              "Please install the `transformers` library, use the _transformers_ extra"
              " for PyKEEN with `pip install pykeen[transformers] when installing, or "
              " see the PyKEEN installation docs at https://pykeen.readthedocs.io/en/stable/installation.html"
              " for more information."
          ) from error
  
      self.tokenizer: PreTrainedTokenizer = AutoTokenizer.from_pretrained(
          pretrained_model_name_or_path=pretrained_model_name_or_path
      )
      self.model = AutoModel.from_pretrained(
          pretrained_model_name_or_path=pretrained_model_name_or_path
      ).to(resolve_device())
      self.max_length = max_length or 512
  
imports: import logging
  import string
  from abc import abstractmethod
  from typing import TYPE_CHECKING, Callable, Optional, Sequence, Union
  import torch
  from class_resolver import ClassResolver, Hint, HintOrType
  from class_resolver.contrib.torch import aggregation_resolver
  from more_itertools import chunked
  from torch import nn
  from torch_max_mem import maximize_memory_utilization
  from tqdm.auto import tqdm
  from ..utils import get_preferred_device, resolve_device, upgrade_to_sequence
label_desc: Use image node_id 1 to create a new TransformerTextEncoder object from inherited base classes: TextEncoder with example: obj = TransformerTextEncoder(pretrained_model_name_or_path, max_length)