code: def test(model, dataloaders, args, max_train_batches=1):
      model.eval()
      accs = {}
      losses = {}
      for mode, dataloader in dataloaders.items():
          acc = 0
          num_batches = 0
          for batch in dataloader:
              batch.to(args.device)
              pred = model(batch)
              # only 1 graph in dataset. In general needs aggregation
              acc += metrics.f1_score(
                  batch.edge_label.cpu().numpy(),
                  model.inference(pred).cpu().numpy(),
                  average="micro",
              )
              num_batches += 1
              if mode == "train" and num_batches >= max_train_batches:
                  # do not eval on the entire training set for efficiency
                  break
          accs[mode] = acc / num_batches
      return accs
  
imports: import copy
  import argparse
  import torch
  import torch.nn
  import torch.nn.functional
  import networkx
  import numpy
  import sklearn.metrics
  import torch_geometric.nn
  from torch.utils.data import DataLoader
  from deepsnap.dataset import GraphDataset
  from deepsnap.batch import Batch
label_desc: Use image node_id 4 for calling a global function with example usage: test(model, dataloaders, args, max_train_batches) and returns: accs