class_docstr: Inductive NodePiece with a GNN encoder on top.
  
  Overall, it's a 3-step procedure:
  
  1. Featurizing nodes via NodePiece
  2. Message passing over the active graph using NodePiece features
  3. Scoring function for a given batch of triples
  
  As of now, message passing is expected to be over the full graph
class_docstr_tok: ["Inductive","NodePiece","with","a","GNN","encoder","on","top",".","Overall",",","it","'s","a","3-step","procedure",":","1",".","Featurizing","nodes","via","NodePiece","2",".","Message","passing","over","the","active","graph","using","NodePiece","features","3",".","Scoring","function","for","a","given","batch","of","triples","As","of","now",",","message","passing","is","expected","to","be","over","the","full","graph"]
docstr: Initialize the model.
  
  :param gnn_encoder:
      an iterable of message passing layers. Defaults to 2-layer CompGCN with Hadamard composition.
  :param kwargs:
      additional keyword-based parameters passed to `InductiveNodePiece.__init__`.
docstr_tok: ["Initialize","the","model",".",":","param","gnn_encoder",":","an","iterable","of","message","passing","layers",".","Defaults","to","2-layer","CompGCN","with","Hadamard","composition",".",":","param","kwargs",":","additional","keyword-based","parameters","passed","to","`","InductiveNodePiece.__init__","`","."]
code: def __init__(
      self,
      *,
      gnn_encoder: Optional[Iterable[nn.Module]] = None,
      **kwargs,
  ) -> None:
      """
      Initialize the model.
  
      :param gnn_encoder:
          an iterable of message passing layers. Defaults to 2-layer CompGCN with Hadamard composition.
      :param kwargs:
          additional keyword-based parameters passed to `InductiveNodePiece.__init__`.
      """
      super().__init__(**kwargs)
  
      (
          train_factory,
          inference_factory,
          validation_factory,
          test_factory,
      ) = (
          kwargs.get("triples_factory"),
          kwargs.get("inference_factory"),
          kwargs.get("validation_factory"),
          kwargs.get("test_factory"),
      )
  
      if gnn_encoder is None:
          # default composition is DistMult-style
          dim = self.entity_representations[0].shape[0]
          gnn_encoder = [
              CompGCNLayer(
                  input_dim=dim,
                  output_dim=dim,
                  activation=torch.nn.ReLU,
                  dropout=0.1,
              )
              for _ in range(2)
          ]
      self.gnn_encoder = nn.ModuleList(gnn_encoder)
  
      # Saving edge indices for all the supplied splits
      assert (
          train_factory is not None
      ), "train_factory must be a valid triples factory"
      self.register_buffer(
          name="training_edge_index",
          tensor=get_edge_index(triples_factory=train_factory),
      )
      self.register_buffer(
          name="training_edge_type",
          tensor=train_factory.mapped_triples[:, 1],
      )
  
      if inference_factory is not None:
          inference_edge_index = get_edge_index(
              triples_factory=inference_factory
          )
          inference_edge_type = inference_factory.mapped_triples[:, 1]
  
          self.register_buffer(
              name="validation_edge_index", tensor=inference_edge_index
          )
          self.register_buffer(
              name="validation_edge_type", tensor=inference_edge_type
          )
          self.register_buffer(
              name="testing_edge_index", tensor=inference_edge_index
          )
          self.register_buffer(
              name="testing_edge_type", tensor=inference_edge_type
          )
      else:
          assert (
              validation_factory is not None
              and test_factory is not None
          ), "Validation and test factories must be triple factories"
          self.register_buffer(
              name="validation_edge_index",
              tensor=get_edge_index(triples_factory=validation_factory),
          )
          self.register_buffer(
              name="validation_edge_type",
              tensor=validation_factory.mapped_triples[:, 1],
          )
          self.register_buffer(
              name="testing_edge_index",
              tensor=get_edge_index(triples_factory=test_factory),
          )
          self.register_buffer(
              name="testing_edge_type",
              tensor=test_factory.mapped_triples[:, 1],
          )
  
file_path: pykeen/src/pykeen/models/inductive/inductive_nodepiece_gnn.py
imports: import logging
  from typing import Iterable, Optional, Tuple, cast
  import torch
  from torch import nn
  from .inductive_nodepiece import InductiveNodePiece
  from ...nn.representation import CompGCNLayer
  from ...typing import HeadRepresentation, InductiveMode, RelationRepresentation, TailRepresentation
  from ...utils import get_edge_index
label_desc: Use image node_id 1 to create a new InductiveNodePieceGNN object from inherited base classes: InductiveNodePiece with example: obj = InductiveNodePieceGNN()