class_docstr: An initializer using pretrained models from the `transformers` library to encode labels.
  
  Example Usage:
  
  Initialize entity representations as Transformer encodings of their labels. Afterwards,
  the parameters are detached from the labels, and trained on the KGE task without any
  further connection to the Transformer model.
  
  .. code-block :: python
  
      from pykeen.datasets import get_dataset
      from pykeen.nn.init import LabelBasedInitializer
      from pykeen.models import ERMLPE
  
      dataset = get_dataset(dataset="nations")
      model = ERMLPE(
          embedding_dim=768,  # for BERT base
          entity_initializer=LabelBasedInitializer.from_triples_factory(
              triples_factory=dataset.training,
              encoder="transformer",
          ),
      )
class_docstr_tok: ["An","initializer","using","pretrained","models","from","the","`","transformers","`","library","to","encode","labels",".","Example","Usage",":","Initialize","entity","representations","as","Transformer","encodings","of","their","labels",".","Afterwards",",","the","parameters","are","detached","from","the","labels",",","and","trained","on","the","KGE","task","without","any","further","connection","to","the","Transformer","model",".","..","code-block",":",":","python","from","pykeen.datasets","import","get_dataset","from","pykeen.nn.init","import","LabelBasedInitializer","from","pykeen.models","import","ERMLPE","dataset","=","get_dataset","(","dataset=","''","nations","''",")","model","=","ERMLPE","(","embedding_dim=768",",","#","for","BERT","base","entity_initializer=LabelBasedInitializer.from_triples_factory","(","triples_factory=dataset.training",",","encoder=","''","transformer","''",",",")",",",")"]
docstr: Initialize the initializer.
  
  :param labels:
      the labels
  :param encoder:
      the text encoder to use, cf. `text_encoder_resolver`
  :param encoder_kwargs:
      additional keyword-based parameters passed to the encoder
  :param batch_size: >0
      the (maximum) batch size to use while encoding. If None, use `len(labels)`, i.e., only a single batch.
docstr_tok: ["Initialize","the","initializer",".",":","param","labels",":","the","labels",":","param","encoder",":","the","text","encoder","to","use",",","cf",".","`","text_encoder_resolver","`",":","param","encoder_kwargs",":","additional","keyword-based","parameters","passed","to","the","encoder",":","param","batch_size",":",">","0","the","(","maximum",")","batch","size","to","use","while","encoding",".","If","None",",","use","`","len","(","labels",")","`",",","i.e.",",","only","a","single","batch","."]
code: def __init__(
      self,
      labels: Sequence[str],
      encoder: HintOrType[TextEncoder] = None,
      encoder_kwargs: OptionalKwargs = None,
      batch_size: Optional[int] = None,
  ):
      """
      Initialize the initializer.
  
      :param labels:
          the labels
      :param encoder:
          the text encoder to use, cf. `text_encoder_resolver`
      :param encoder_kwargs:
          additional keyword-based parameters passed to the encoder
      :param batch_size: >0
          the (maximum) batch size to use while encoding. If None, use `len(labels)`, i.e., only a single batch.
      """
      super().__init__(
          tensor=text_encoder_resolver.make(
              encoder, encoder_kwargs
          ).encode_all(
              labels=labels,
              batch_size=batch_size,
          )
          # must be cloned if we want to do backprop
          .clone(),
      )
  
imports: import functools
  import logging
  import math
  from typing import Any, Optional, Sequence
  import numpy
  import torch
  import torch.nn
  import torch.nn.init
  import torch_ppr.utils
  from class_resolver import FunctionResolver, Hint, HintOrType, OptionalKwargs
  from more_itertools import last
  from torch.nn import functional
  from .text import TextEncoder, text_encoder_resolver
  from .utils import iter_matrix_power, safe_diagonal
  from ..triples import CoreTriplesFactory, TriplesFactory
  from ..typing import Initializer, MappedTriples, OneOrSequence
  from ..utils import compose, get_edge_index, iter_weisfeiler_lehman, upgrade_to_sequence
label_desc: Use image node_id 1 to create a new LabelBasedInitializer object from inherited base classes: PretrainedInitializer with example: obj = LabelBasedInitializer(labels, encoder, encoder_kwargs, batch_size)