code: def compute_mrr(z, edge_index, edge_type):
      ranks = []
      for i in tqdm(range(edge_type.numel())):
          (src, dst), rel = edge_index[:, i], edge_type[i]
  
          # Try all nodes as tails, but delete true triplets:
          tail_mask = torch.ones(data.num_nodes, dtype=torch.bool)
          for (heads, tails), types in [
              (data.train_edge_index, data.train_edge_type),
              (data.valid_edge_index, data.valid_edge_type),
              (data.test_edge_index, data.test_edge_type),
          ]:
              tail_mask[tails[(heads == src) & (types == rel)]] = False
  
          tail = torch.arange(data.num_nodes)[tail_mask]
          tail = torch.cat([torch.tensor([dst]), tail])
          head = torch.full_like(tail, fill_value=src)
          eval_edge_index = torch.stack([head, tail], dim=0)
          eval_edge_type = torch.full_like(tail, fill_value=rel)
  
          out = model.decode(z, eval_edge_index, eval_edge_type)
          rank = compute_rank(out)
          ranks.append(rank)
  
          # Try all nodes as heads, but delete true triplets:
          head_mask = torch.ones(data.num_nodes, dtype=torch.bool)
          for (heads, tails), types in [
              (data.train_edge_index, data.train_edge_type),
              (data.valid_edge_index, data.valid_edge_type),
              (data.test_edge_index, data.test_edge_type),
          ]:
              head_mask[heads[(tails == dst) & (types == rel)]] = False
  
          head = torch.arange(data.num_nodes)[head_mask]
          head = torch.cat([torch.tensor([src]), head])
          tail = torch.full_like(head, fill_value=dst)
          eval_edge_index = torch.stack([head, tail], dim=0)
          eval_edge_type = torch.full_like(head, fill_value=rel)
  
          out = model.decode(z, eval_edge_index, eval_edge_type)
          rank = compute_rank(out)
          ranks.append(rank)
  
      return (1.0 / torch.tensor(ranks, dtype=torch.float)).mean()
  
imports: import os.path
  import time
  import torch
  import torch.nn.functional
  from torch.nn import Parameter
  from tqdm import tqdm
  from torch_geometric.datasets import RelLinkPredDataset
  from torch_geometric.nn import GAE, RGCNConv
label_desc: Use image node_id 5 for calling a global function with example usage: compute_mrr(z, edge_index, edge_type) and returns: unknown