class_docstr: An initializer based on an encoding of categorical colors from the Weisfeiler-Lehman algorithm.
class_docstr_tok: ["An","initializer","based","on","an","encoding","of","categorical","colors","from","the","Weisfeiler-Lehman","algorithm","."]
docstr: Initialize the initializer.
  
  :param color_initializer:
      the initializer for initialization color representations, or a hint thereof
  :param color_initializer_kwargs:
      additional keyword-based parameters for the color initializer
  :param shape:
      the shape to use for the color representations
  
  :param edge_index: shape: (2, m)
      the edge index
  :param num_entities:
      the number of entities. can be inferred
  :param mapped_triples: shape: (m, 3)
      the Id-based triples
  :param triples_factory:
      the triples factory
  
  :param kwargs:
      additional keyword-based parameters passed to :func:`pykeen.utils.iter_weisfeiler_lehman`
docstr_tok: ["Initialize","the","initializer",".",":","param","color_initializer",":","the","initializer","for","initialization","color","representations",",","or","a","hint","thereof",":","param","color_initializer_kwargs",":","additional","keyword-based","parameters","for","the","color","initializer",":","param","shape",":","the","shape","to","use","for","the","color","representations",":","param","edge_index",":","shape",":","(","2",",","m",")","the","edge","index",":","param","num_entities",":","the","number","of","entities",".","can","be","inferred",":","param","mapped_triples",":","shape",":","(","m",",","3",")","the","Id-based","triples",":","param","triples_factory",":","the","triples","factory",":","param","kwargs",":","additional","keyword-based","parameters","passed","to",":","func",":","`","pykeen.utils.iter_weisfeiler_lehman","`"]
code: def __init__(
      self,
      *,
      # the color initializer
      color_initializer: Hint[Initializer] = None,
      color_initializer_kwargs: OptionalKwargs = None,
      shape: OneOrSequence[int] = 32,
      # variants for the edge index
      edge_index: Optional[torch.LongTensor] = None,
      num_entities: Optional[int] = None,
      mapped_triples: Optional[torch.LongTensor] = None,
      triples_factory: Optional[CoreTriplesFactory] = None,
      # additional parameters for iter_weisfeiler_lehman
      **kwargs,
  ) -> None:
      """
      Initialize the initializer.
  
      :param color_initializer:
          the initializer for initialization color representations, or a hint thereof
      :param color_initializer_kwargs:
          additional keyword-based parameters for the color initializer
      :param shape:
          the shape to use for the color representations
  
      :param edge_index: shape: (2, m)
          the edge index
      :param num_entities:
          the number of entities. can be inferred
      :param mapped_triples: shape: (m, 3)
          the Id-based triples
      :param triples_factory:
          the triples factory
  
      :param kwargs:
          additional keyword-based parameters passed to :func:`pykeen.utils.iter_weisfeiler_lehman`
      """
      # normalize shape
      shape = upgrade_to_sequence(shape)
      # get coloring
      colors = last(
          iter_weisfeiler_lehman(
              edge_index=get_edge_index(
                  triples_factory=triples_factory,
                  mapped_triples=mapped_triples,
                  edge_index=edge_index,
              ),
              num_nodes=num_entities,
              **kwargs,
          )
      )
      # make color initializer
      color_initializer = initializer_resolver.make(
          color_initializer, pos_kwargs=color_initializer_kwargs
      )
      # initialize color representations
      num_colors = colors.max().item() + 1
      # note: this could be a representation?
      color_representation = color_initializer(
          colors.new_empty(
              num_colors, *shape, dtype=torch.get_default_dtype()
          )
      )
      # init entity representations according to the color
      super().__init__(tensor=color_representation[colors])
  
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 WeisfeilerLehmanInitializer object from inherited base classes: PretrainedInitializer with example: obj = WeisfeilerLehmanInitializer()