class_docstr: Runs the training of an augmented samples generator model which uses the
  already trained reward generation model. For a given graph, the model
  generates an augmented sample and a likelihood that this is a label
  invariant augmentation. This prediction is then evaluated by the reward
  generation model and a loss is computed based on these metrics. The loss
  is then minimized through training. Check
  :obj:`examples.auggraph.GraphAug.run_generator` for examples on how to
  run the generator 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.generator_conf` for
          examples on how to define the conf dictionary for the generator.
class_docstr_tok: ["Runs","the","training","of","an","augmented","samples","generator","model","which","uses","the","already","trained","reward","generation","model",".","For","a","given","graph",",","the","model","generates","an","augmented","sample","and","a","likelihood","that","this","is","a","label","invariant","augmentation",".","This","prediction","is","then","evaluated","by","the","reward","generation","model","and","a","loss","is","computed","based","on","these","metrics",".","The","loss","is","then","minimized","through","training",".","Check",":","obj",":","`","examples.auggraph.GraphAug.run_generator","`","for","examples","on","how","to","run","the","generator","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.generator_conf","`","for","examples","on","how","to","define","the","conf","dictionary","for","the","generator","."]
docstr: This method is used to run the training for the augmented samples
  generator and validate the epoch parameters.
  
  Args:
       results_path (string): Directory where the resulting optimal
          parameters of the generator model will be saved.
docstr_tok: ["This","method","is","used","to","run","the","training","for","the","augmented","samples","generator","and","validate","the","epoch","parameters",".","Args",":","results_path","(","string",")",":","Directory","where","the","resulting","optimal","parameters","of","the","generator","model","will","be","saved","."]
code: def train_test(self, results_path):
      r"""
      This method is used to run the training for the augmented samples
      generator and validate the epoch parameters.
  
      Args:
           results_path (string): Directory where the resulting optimal
              parameters of the generator model will be saved.
      """
      self.reward_generator, self.generator = self.reward_generator.to(
          self.device
      ), self.generator.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_path = os.path.join(
          out_path,
          "max_augs_{}".format(
              self.conf[GENERATOR_PARAMS][MAX_NUM_AUG]
          ),
      )
      if not os.path.isdir(model_path):
          os.mkdir(model_path)
  
      self.out_path = out_path
      val_record_file = "val_record.txt"
      f = open(os.path.join(model_path, val_record_file), "a")
      f.write(
          "Generator results for dataset {} using augmentation below\n".format(
              self.dataset_name
          )
      )
      for aug_type in self.conf[GENERATOR_PARAMS][AUG_TYPE_PARAMS]:
          f.write(
              "{}: {}\n".format(
                  aug_type,
                  self.conf[GENERATOR_PARAMS][AUG_TYPE_PARAMS][
                      aug_type
                  ],
              )
          )
      f.close()
  
      train_loader = DataLoader(
          self.train_set,
          batch_size=self.conf[BATCH_SIZE],
          shuffle=True,
          num_workers=8,
      )
  
      optimizer = torch.optim.Adam(
          self.generator.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 epoch % self.conf[TEST_INTERVAL] == 0:
              val_acc, avg_reward = self.test()
              print(
                  "Epoch {}, validation accuracy {}, average reward {}".format(
                      epoch, val_acc, avg_reward
                  )
              )
  
              f = open(os.path.join(out_path, val_record_file), "a")
              f.write(
                  "Epoch {}, validation accuracy {}, average reward {}\n".format(
                      epoch, val_acc, avg_reward
                  )
              )
              f.close()
  
          if self.conf[SAVE_MODEL]:
              torch.save(
                  self.generator.state_dict(),
                  os.path.join(
                      model_path, "{}.pt".format(str(epoch).zfill(4))
                  ),
              )
  
file_path: DIG/dig/auggraph/method/GraphAug/runner_generator.py
imports: import os
  import torch
  from torch_geometric.loader import DataLoader
  from torch_geometric.data import Batch
  from torch_geometric.datasets import TUDataset
  from .model import RewardGenModel
  from dig.auggraph.dataset.aug_dataset import Subset, DegreeTrans
  from .aug import Augmenter
  from dig.auggraph.method.GraphAug.constants import *
label_desc: Use image node_id 6 for calling the RunnerGenerator obj's underlying member method code with example usage: obj.train_test(results_path) without return types