class_docstr: Runs the training of a reward generation model which will be able to
  distinguish between graphs with different labels. Check
  :obj:`examples.auggraph.GraphAug.run_reward_gen` for examples on how
  to run the reward generation model.
  
  Args:
      data_root_path (string): Directory where datasets should be saved.
      dataset_name (:class:`dig.auggraph.method.GraphAug.constants.enums.DatasetName`):
          Name of the graph dataset.
      conf (dict): Hyperparameters for the model. Check
          :obj:`examples.auggraph.GraphAug.conf.reward_gen_conf` for examples
          on how to define the conf dictionary for the reward generator.
docstr: This method is used to run the training for the reward generation
  model and validate the epoch parameters.
  
  Args:
      results_path (string): Directory where the resulting optimal
          parameters of the reward generation model will be saved.
      num_save (int): Number of final epochs for which model
          parameters will be saved.
docstr_tok: ["This","method","is","used","to","run","the","training","for","the","reward","generation","model","and","validate","the","epoch","parameters",".","Args",":","results_path","(","string",")",":","Directory","where","the","resulting","optimal","parameters","of","the","reward","generation","model","will","be","saved",".","num_save","(","int",")",":","Number","of","final","epochs","for","which","model","parameters","will","be","saved","."]
code: def train_test(self, results_path, num_save=30):
      r"""
      This method is used to run the training for the reward generation
      model and validate the epoch parameters.
  
      Args:
          results_path (string): Directory where the resulting optimal
              parameters of the reward generation model will be saved.
          num_save (int): Number of final epochs for which model
              parameters will be saved.
      """
      self.model = self.model.to(self.device)
  
      out_path = os.path.join(results_path, self.dataset_name.value)
      if not os.path.isdir(out_path):
          os.makedirs(out_path)
  
      model_dir_name = self.conf[REWARD_GEN_PARAMS][MODEL_TYPE]
      model_dir = os.path.join(out_path, model_dir_name.value)
      if not os.path.isdir(model_dir):
          os.mkdir(model_dir)
  
      log_file = "record.txt"
      f = open(os.path.join(out_path, log_file), "a")
      f.write(
          "Reward generator classification results for dataset {} with model parameters {}\n".format(
              self.dataset_name, self.conf[REWARD_GEN_PARAMS]
          )
      )
      f.close()
  
      train_loader = DataLoader(
          self.train_set,
          batch_size=self.conf[BATCH_SIZE],
          shuffle=True,
          num_workers=16,
      )
      val_loader = DataLoader(
          self.val_set, batch_size=self.conf[BATCH_SIZE], shuffle=True
      )
  
      optimizer = torch.optim.Adam(
          self.model.parameters(),
          lr=self.conf[INITIAL_LR],
          weight_decay=1e-4,
      )
  
      for epoch in range(self.conf[MAX_NUM_EPOCHS]):
          self._train_epoch(train_loader, optimizer)
          if (
              model_dir_name is not None
              and epoch > self.conf[MAX_NUM_EPOCHS] - num_save
          ):
              torch.save(
                  self.model.state_dict(),
                  os.path.join(
                      model_dir, "{}.pt".format(str(epoch).zfill(4))
                  ),
              )
          val_acc, val_pos_acc, val_neg_acc = self.test(val_loader)
          print(
              "Epoch {}, validation accuracy {}, accuracy of positive samples {}, accuracy of negative samples {}".format(
                  epoch, val_acc, val_pos_acc, val_neg_acc
              )
          )
  
          f = open(os.path.join(out_path, log_file), "a")
          f.write(
              "Epoch {}, validation accuracy {}, accuracy of positive samples {}, accuracy of negative samples {}\n".format(
                  epoch, val_acc, val_pos_acc, val_neg_acc
              )
          )
          f.close()
  
file_path: DIG/dig/auggraph/method/GraphAug/runner_reward_gen.py
imports: import os
  import torch
  import torch.nn.functional
  from torch_geometric.loader import DataLoader
  from torch_geometric.datasets import TUDataset
  from .model import RewardGenModel
  from dig.auggraph.dataset.aug_dataset import DegreeTrans, TripleSet
  from dig.auggraph.method.GraphAug.constants import *
label_desc: Use image node_id 6 for calling the RunnerRewardGen obj's underlying member method code with example usage: obj.train_test(results_path, num_save) without return types