class_docstr: Tokenize entities by representing them as a bag of anchor entities.
  
  The entities are chosen by shortest path distance.
class_docstr_tok: ["Tokenize","entities","by","representing","them","as","a","bag","of","anchor","entities",".","The","entities","are","chosen","by","shortest","path","distance","."]
docstr: Initialize the tokenizer.
  
  :param selection:
      the anchor node selection strategy.
  :param selection_kwargs:
      additional keyword-based arguments passed to the selection strategy
  :param searcher:
      the component for searching the closest anchors for each entity
  :param searcher_kwargs:
      additional keyword-based arguments passed to the searcher
docstr_tok: ["Initialize","the","tokenizer",".",":","param","selection",":","the","anchor","node","selection","strategy",".",":","param","selection_kwargs",":","additional","keyword-based","arguments","passed","to","the","selection","strategy",":","param","searcher",":","the","component","for","searching","the","closest","anchors","for","each","entity",":","param","searcher_kwargs",":","additional","keyword-based","arguments","passed","to","the","searcher"]
code: def __init__(
      self,
      # TODO: expose num_anchors?
      selection: HintOrType[AnchorSelection] = None,
      selection_kwargs: OptionalKwargs = None,
      searcher: HintOrType[AnchorSearcher] = None,
      searcher_kwargs: OptionalKwargs = None,
  ) -> None:
      """
      Initialize the tokenizer.
  
      :param selection:
          the anchor node selection strategy.
      :param selection_kwargs:
          additional keyword-based arguments passed to the selection strategy
      :param searcher:
          the component for searching the closest anchors for each entity
      :param searcher_kwargs:
          additional keyword-based arguments passed to the searcher
      """
      self.anchor_selection = anchor_selection_resolver.make(
          selection, pos_kwargs=selection_kwargs
      )
      self.searcher = anchor_searcher_resolver.make(
          searcher, pos_kwargs=searcher_kwargs
      )
  
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 1 to create a new AnchorTokenizer object from inherited base classes: Tokenizer with example: obj = AnchorTokenizer(selection, selection_kwargs, searcher, searcher_kwargs)