class_docstr: A module holding the result of tokenization.
  
  ---
  name: Tokenization
  citation:
      author: Galkin
      year: 2021
      link: https://arxiv.org/abs/2106.12144
      github: https://github.com/migalkin/NodePiece
class_docstr_tok: ["A","module","holding","the","result","of","tokenization",".","--","-","name",":","Tokenization","citation",":","author",":","Galkin","year",":","2021","link",":","https",":","\/\/arxiv.org\/abs\/2106.12144","github",":","https",":","\/\/github.com\/migalkin\/NodePiece"]
docstr: Create a tokenization from applying a tokenizer.
  
  :param tokenizer:
      the tokenizer instance.
  :param num_tokens:
      the number of tokens to select for each entity.
  :param token_representation:
      the pre-instantiated token representations, class, or name of a class
  :param token_representation_kwargs:
      additional keyword-based parameters
  :param mapped_triples:
      the ID-based triples
  :param num_entities:
      the number of entities
  :param num_relations:
      the number of relations
  :param kwargs:
      additional keyword-based parameters passed to TokenizationRepresentation.__init__
  :return:
      A tokenization representation by applying the tokenizer
docstr_tok: ["Create","a","tokenization","from","applying","a","tokenizer",".",":","param","tokenizer",":","the","tokenizer","instance",".",":","param","num_tokens",":","the","number","of","tokens","to","select","for","each","entity",".",":","param","token_representation",":","the","pre-instantiated","token","representations",",","class",",","or","name","of","a","class",":","param","token_representation_kwargs",":","additional","keyword-based","parameters",":","param","mapped_triples",":","the","ID-based","triples",":","param","num_entities",":","the","number","of","entities",":","param","num_relations",":","the","number","of","relations",":","param","kwargs",":","additional","keyword-based","parameters","passed","to","TokenizationRepresentation.__init__",":","return",":","A","tokenization","representation","by","applying","the","tokenizer"]
code: def from_tokenizer(
      cls,
      tokenizer: Tokenizer,
      num_tokens: int,
      mapped_triples: MappedTriples,
      num_entities: int,
      num_relations: int,
      token_representation: HintOrType[Representation] = None,
      token_representation_kwargs: OptionalKwargs = None,
      **kwargs,
  ) -> "TokenizationRepresentation":
      """
      Create a tokenization from applying a tokenizer.
  
      :param tokenizer:
          the tokenizer instance.
      :param num_tokens:
          the number of tokens to select for each entity.
      :param token_representation:
          the pre-instantiated token representations, class, or name of a class
      :param token_representation_kwargs:
          additional keyword-based parameters
      :param mapped_triples:
          the ID-based triples
      :param num_entities:
          the number of entities
      :param num_relations:
          the number of relations
      :param kwargs:
          additional keyword-based parameters passed to TokenizationRepresentation.__init__
      :return:
          A tokenization representation by applying the tokenizer
      """
      # apply tokenizer
      vocabulary_size, assignment = tokenizer(
          mapped_triples=mapped_triples,
          num_tokens=num_tokens,
          num_entities=num_entities,
          num_relations=num_relations,
      )
      return TokenizationRepresentation(
          assignment=assignment,
          token_representation=token_representation,
          token_representation_kwargs=token_representation_kwargs,
          **kwargs,
      )
  
imports: import logging
  import pathlib
  from typing import Callable, Iterable, List, NamedTuple, Optional, Union
  import torch
  from class_resolver import HintOrType, OneOrManyHintOrType, OneOrManyOptionalKwargs, OptionalKwargs
  from docdata import parse_docdata
  from .tokenization import Tokenizer, tokenizer_resolver
  from ..combination import ConcatAggregationCombination
  from ..perceptron import ConcatMLP
  from ..representation import CombinedRepresentation, Representation
  from ..utils import ShapeError
  from ...triples import CoreTriplesFactory
  from ...typing import MappedTriples, OneOrSequence
  from ...utils import broadcast_upgrade_to_sequences
label_desc: Use image node_id 2 for calling the TokenizationRepresentation obj's underlying member method code with example usage: obj.from_tokenizer(cls, tokenizer, num_tokens, mapped_triples, num_entities, num_relations, token_representation, token_representation_kwargs) and returns: TokenizationRepresentation