class_docstr: The WordNet18RR dataset from the `"Convolutional 2D Knowledge Graph
  Embeddings" <https://arxiv.org/abs/1707.01476>`_ paper, containing 40,943
  entities, 11 relations and 93,003 fact triplets.
  
  Args:
      root (str): Root directory where the dataset should be saved.
      transform (callable, optional): A function/transform that takes in an
          :obj:`torch_geometric.data.Data` object and returns a transformed
          version. The data object will be transformed before every access.
          (default: :obj:`None`)
      pre_transform (callable, optional): A function/transform that takes in
          an :obj:`torch_geometric.data.Data` object and returns a
          transformed version. The data object will be transformed before
          being saved to disk. (default: :obj:`None`)
      force_reload (bool, optional): Whether to re-process the dataset.
          (default: :obj:`False`)
class_docstr_tok: ["The","WordNet18RR","dataset","from","the","`","``","Convolutional","2D","Knowledge","Graph","Embeddings","''","<","https",":","\/\/arxiv.org\/abs\/1707.01476",">","`","_","paper",",","containing","40,943","entities",",","11","relations","and","93,003","fact","triplets",".","Args",":","root","(","str",")",":","Root","directory","where","the","dataset","should","be","saved",".","transform","(","callable",",","optional",")",":","A","function\/transform","that","takes","in","an",":","obj",":","`","torch_geometric.data.Data","`","object","and","returns","a","transformed","version",".","The","data","object","will","be","transformed","before","every","access",".","(","default",":",":","obj",":","`","None","`",")","pre_transform","(","callable",",","optional",")",":","A","function\/transform","that","takes","in","an",":","obj",":","`","torch_geometric.data.Data","`","object","and","returns","a","transformed","version",".","The","data","object","will","be","transformed","before","being","saved","to","disk",".","(","default",":",":","obj",":","`","None","`",")","force_reload","(","bool",",","optional",")",":","Whether","to","re-process","the","dataset",".","(","default",":",":","obj",":","`","False","`",")"]
code: def process(self) -> None:
      node2id, idx = {}, 0
  
      srcs, dsts, edge_types = [], [], []
      for path in self.raw_paths:
          with open(path, "r") as f:
              edges = f.read().split()
  
              _src = edges[::3]
              _dst = edges[2::3]
              _edge_type = edges[1::3]
  
              for i in chain(_src, _dst):
                  if i not in node2id:
                      node2id[i] = idx
                      idx += 1
  
              srcs.append(torch.tensor([node2id[i] for i in _src]))
              dsts.append(torch.tensor([node2id[i] for i in _dst]))
              edge_types.append(
                  torch.tensor([self.edge2id[i] for i in _edge_type])
              )
  
      src = torch.cat(srcs, dim=0)
      dst = torch.cat(dsts, dim=0)
      edge_type = torch.cat(edge_types, dim=0)
  
      train_mask = torch.zeros(src.size(0), dtype=torch.bool)
      train_mask[: srcs[0].size(0)] = True
      val_mask = torch.zeros(src.size(0), dtype=torch.bool)
      val_mask[
          srcs[0].size(0) : srcs[0].size(0) + srcs[1].size(0)
      ] = True
      test_mask = torch.zeros(src.size(0), dtype=torch.bool)
      test_mask[srcs[0].size(0) + srcs[1].size(0) :] = True
  
      num_nodes = max(int(src.max()), int(dst.max())) + 1
      _, perm = index_sort(num_nodes * src + dst)
  
      edge_index = torch.stack([src[perm], dst[perm]], dim=0)
      edge_type = edge_type[perm]
      train_mask = train_mask[perm]
      val_mask = val_mask[perm]
      test_mask = test_mask[perm]
  
      data = Data(
          edge_index=edge_index,
          edge_type=edge_type,
          train_mask=train_mask,
          val_mask=val_mask,
          test_mask=test_mask,
          num_nodes=num_nodes,
      )
  
      if self.pre_transform is not None:
          data = self.pre_transform(data)
  
      self.save([data], self.processed_paths[0])
  
file_path: pytorch_geometric/torch_geometric/datasets/word_net.py
imports: from itertools import chain
  from typing import Callable, List, Optional
  import torch
  from torch_geometric.data import Data, InMemoryDataset, download_url
  from torch_geometric.utils import index_sort
label_desc: Use image node_id 5 for calling the WordNet18RR obj's underlying member method code with example usage: obj.process() without return types