class_docstr: Load OGBL-WikiKG2 from files.
      
class_docstr_tok: ["Load","OGBL-WikiKG2","from","files","."]
code: def __init__(self, path):
      super(WikiKG2Dataset, self).__init__()
      self.name = "OGBL-WikiKG2"
      try:
          from ogb.linkproppred import LinkPropPredDataset
      except ImportError as error:
          print(
              "Please run ``pip install ogb==1.3.1`` to load OGBL-WikiKG2 dataset."
          )
          raise ImportError(error)
      data = LinkPropPredDataset(name="ogbl-wikikg2", root=path)
      split_idx = data.get_edge_split()
      valid = split_idx["valid"]
      test = split_idx["test"]
      self.triplets = {
          "train": np.stack(
              [
                  split_idx["train"]["head"],
                  split_idx["train"]["relation"],
                  split_idx["train"]["tail"],
              ]
          ).T,
          "valid": {
              "mode": "wikikg2",
              "h": valid["head"],
              "r": valid["relation"],
              "t": valid["tail"],
              "candidate_h": valid["head_neg"],
              "candidate_t": valid["tail_neg"],
          },
          "test": {
              "mode": "wikikg2",
              "h": test["head"],
              "r": test["relation"],
              "t": test["tail"],
              "candidate_h": test["head_neg"],
              "candidate_t": test["tail_neg"],
          },
      }
      self.num_ents = data.graph["num_nodes"]
      self.num_rels = int(max(data.graph["edge_reltype"])[0]) + 1
      self.ent_feat = None
      self.rel_feat = None
  
imports: import os
  import time
  import numpy
  import paddle.distributed
  from dataset.trigraph import TriGraph
  from utils import timer_wrapper
label_desc: Use image node_id 1 to create a new WikiKG2Dataset object from inherited base classes: object with example: obj = WikiKG2Dataset(path)