class_docstr: A tokenizer using externally precomputed tokenization.
class_docstr_tok: ["A","tokenizer","using","externally","precomputed","tokenization","."]
docstr: Initialize the tokenizer.
  
  .. note ::
      the preference order for loading the precomputed pools is (1) from the given pool (2) from the given path,
      and (3) by downloading from the given url
  
  :param path:
      a path for a file containing the precomputed pools
  :param url:
      an url to download the file with precomputed pools from
  :param download_kwargs:
      additional download parameters, passed to pystow.Module.ensure
  :param pool:
      the precomputed pools.
  :param randomize_selection:
      whether to randomly choose from tokens, or always take the first `num_token` precomputed tokens.
  :param loader:
      the loader to use for loading the pool
  :raises ValueError: If the pool's keys are not contiguous on $0 \dots N-1$.
docstr_tok: ["Initialize","the","tokenizer",".","..","note",":",":","the","preference","order","for","loading","the","precomputed","pools","is","(","1",")","from","the","given","pool","(","2",")","from","the","given","path",",","and","(","3",")","by","downloading","from","the","given","url",":","param","path",":","a","path","for","a","file","containing","the","precomputed","pools",":","param","url",":","an","url","to","download","the","file","with","precomputed","pools","from",":","param","download_kwargs",":","additional","download","parameters",",","passed","to","pystow.Module.ensure",":","param","pool",":","the","precomputed","pools",".",":","param","randomize_selection",":","whether","to","randomly","choose","from","tokens",",","or","always","take","the","first","`","num_token","`","precomputed","tokens",".",":","param","loader",":","the","loader","to","use","for","loading","the","pool",":","raises","ValueError",":","If","the","pool","'s","keys","are","not","contiguous","on","$","0","\\dots","N-1","$","."]
code: def __init__(
      self,
      *,
      path: Optional[pathlib.Path] = None,
      url: Optional[str] = None,
      download_kwargs: OptionalKwargs = None,
      pool: Optional[Mapping[int, Collection[int]]] = None,
      randomize_selection: bool = False,
      loader: HintOrType[PrecomputedTokenizerLoader] = None,
  ):
      r"""
      Initialize the tokenizer.
  
      .. note ::
          the preference order for loading the precomputed pools is (1) from the given pool (2) from the given path,
          and (3) by downloading from the given url
  
      :param path:
          a path for a file containing the precomputed pools
      :param url:
          an url to download the file with precomputed pools from
      :param download_kwargs:
          additional download parameters, passed to pystow.Module.ensure
      :param pool:
          the precomputed pools.
      :param randomize_selection:
          whether to randomly choose from tokens, or always take the first `num_token` precomputed tokens.
      :param loader:
          the loader to use for loading the pool
      :raises ValueError: If the pool's keys are not contiguous on $0 \dots N-1$.
      """
      self.pool, self.vocabulary_size = self._load_pool(
          path=path,
          url=url,
          pool=pool,
          download_kwargs=download_kwargs,
          loader=loader,
      )
      # verify pool
      if set(self.pool.keys()) != set(range(len(self.pool))):
          raise ValueError(
              "Expected pool to contain contiguous keys 0...(N-1)"
          )
      self.randomize_selection = randomize_selection
  
imports: import logging
  import pathlib
  from abc import abstractmethod
  from collections import defaultdict
  from typing import Collection, Mapping, Optional, Tuple
  import more_itertools
  import numpy
  import torch
  from class_resolver import ClassResolver, HintOrType, OptionalKwargs
  from .anchor_search import AnchorSearcher, anchor_searcher_resolver
  from .anchor_selection import AnchorSelection, anchor_selection_resolver
  from .loader import PrecomputedTokenizerLoader, precomputed_tokenizer_loader_resolver
  from .utils import prepare_edges_for_metis, random_sample_no_replacement
  from ...constants import PYKEEN_MODULE
  from ...typing import DeviceHint, MappedTriples
  from ...utils import format_relative_comparison, get_edge_index, resolve_device
label_desc: Use image node_id 2 to create a new PrecomputedPoolTokenizer object from inherited base classes: Tokenizer with example: obj = PrecomputedPoolTokenizer()