code: def gae_for(args):
      print("Using {} dataset".format(args.dataset_str))
      adj, features = load_data(args.dataset_str)
      n_nodes, feat_dim = features.shape
  
      # Store original adjacency matrix (without diagonal entries) for later
      adj_orig = adj
      adj_orig = adj_orig - sp.dia_matrix(
          (adj_orig.diagonal()[np.newaxis, :], [0]),
          shape=adj_orig.shape,
      )
      adj_orig.eliminate_zeros()
  
      (
          adj_train,
          train_edges,
          val_edges,
          val_edges_false,
          test_edges,
          test_edges_false,
      ) = mask_test_edges(adj)
      adj = adj_train
  
      # Some preprocessing
      adj_norm = preprocess_graph(adj)
      adj_label = adj_train + sp.eye(adj_train.shape[0])
      # adj_label = sparse_to_tuple(adj_label)
      adj_label = torch.FloatTensor(adj_label.toarray())
  
      pos_weight = (
          float(adj.shape[0] * adj.shape[0] - adj.sum()) / adj.sum()
      )
      norm = (
          adj.shape[0]
          * adj.shape[0]
          / float((adj.shape[0] * adj.shape[0] - adj.sum()) * 2)
      )
  
      model = GCNModelVAE(
          feat_dim,
          args.hidden1,
          args.hidden2,
          args.dropout,
          args.prediction_type,
      )
      optimizer = optim.Adam(model.parameters(), lr=args.lr)
      # softmax = torch.nn.Softmax(dim=1)
      hidden_emb = None
      for epoch in range(args.epochs):
          t = time.time()
          model.train()
          optimizer.zero_grad()
          sample, mu, logvar, recovered = model(features, adj_norm)
          loss = loss_function(
              preds=sample.view(-1),
              labels=adj_label.view(-1),
              mu=mu,
              logvar=logvar,
              n_nodes=n_nodes,
              norm=norm,
              weight=pos_weight,
          )
          loss.backward()
          cur_loss = loss.item()
          optimizer.step()
  
          hidden_emb = mu.data.numpy()
          recovered = recovered.data.numpy()
          num_node = hidden_emb.shape[0]
          recovered_label = recovered.reshape(num_node, num_node)
          roc_curr, ap_curr = get_roc_score(
              recovered_label, adj_orig, val_edges, val_edges_false
          )
  
          print(
              "Epoch:",
              "%04d" % (epoch + 1),
              "train_loss=",
              "{:.5f}".format(cur_loss),
              "val_ap=",
              "{:.5f}".format(ap_curr),
              "time=",
              "{:.5f}".format(time.time() - t),
          )
  
      print("Optimization Finished!")
  
      roc_score, ap_score = get_roc_score(
          recovered_label, adj_orig, test_edges, test_edges_false
      )
      print("Test ROC score: " + str(roc_score))
      print("Test AP score: " + str(ap_score))
  
file_path: graph4nlp/graph4nlp/pytorch/test/link_prediction/link_prediction_test.py
imports: from __future__ import division, print_function
  import argparse
  import time
  import numpy
  import scipy.sparse
  import torch
  from torch import optim
  from model import GCNModelVAE
  from optimizer import loss_function
  from utils import get_roc_score, load_data, mask_test_edges, preprocess_graph
label_desc: Use image node_id 1 for calling a global function with example usage: gae_for(args) without return types