code: def grid_search_main(config):
      grid_search_hyperparams = []
      log_path = config["out_dir"]
      for k, v in config.items():
          if isinstance(v, list):
              grid_search_hyperparams.append(k)
              log_path += "_{}_{}".format(k, v)
  
      logger = Logger(log_path, config=config, overwrite=True)
  
      best_config = None
      best_score = -1
      configs = grid(config)
      for cnf in configs:
          for k in grid_search_hyperparams:
              cnf["out_dir"] += "_{}_{}".format(k, cnf[k])
  
          val_score, test_score = main(cnf)
          if best_score < test_score:
              best_score = test_score
              best_config = cnf
              print(
                  "Found a better configuration: {}".format(best_score)
              )
              logger.write(
                  "Found a better configuration: {}".format(best_score)
              )
  
      print("\nBest configuration:")
      logger.write("\nBest configuration:")
      for k in grid_search_hyperparams:
          print("{}: {}".format(k, best_config[k]))
          logger.write("{}: {}".format(k, best_config[k]))
  
      print("Best score: {}".format(best_score))
      logger.write("Best score: {}\n".format(best_score))
      logger.close()
  
imports: import argparse
  import os
  import time
  import numpy
  import torch
  import torch.backends.cudnn
  import torch.multiprocessing
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import yaml
  from torch.optim.lr_scheduler import ReduceLROnPlateau
  from torch.utils.data import DataLoader
  from graph4nlp.pytorch.datasets.trec import TrecDataset
  from graph4nlp.pytorch.modules.evaluation.accuracy import Accuracy
  from graph4nlp.pytorch.modules.graph_construction import NodeEmbeddingBasedGraphConstruction, NodeEmbeddingBasedRefinedGraphConstruction
  from graph4nlp.pytorch.modules.graph_embedding_initialization.embedding_construction import WordEmbedding
  from graph4nlp.pytorch.modules.graph_embedding_initialization.graph_embedding_initialization import GraphEmbeddingInitialization
  from graph4nlp.pytorch.modules.graph_embedding_learning import GAT, GGNN, GraphSAGE
  from graph4nlp.pytorch.modules.loss.general_loss import GeneralLoss
  from graph4nlp.pytorch.modules.prediction.classification.graph_classification import FeedForwardNN
  from graph4nlp.pytorch.modules.utils import constants
  from graph4nlp.pytorch.modules.utils.generic_utils import EarlyStopping, grid, to_cuda
  from graph4nlp.pytorch.modules.utils.logger import Logger
label_desc: Use image node_id 5 for calling a global function with example usage: grid_search_main(config) without return types