class_docstr: Argument configuration for knowledge representation learning
      
code: def __init__(self):
      super(KGEArgParser, self).__init__()
      self.basic_group = self.add_argument_group(
          "basic", "required arguments."
      )
  
      self.basic_group.add_argument(
          "--seed",
          type=int,
          default=0,
          help="Random seed for initialization.",
      )
  
      self.basic_group.add_argument(
          "--data_path",
          type=str,
          default="./data/",
          help="Directory of knowledge graph dataset.",
      )
  
      self.basic_group.add_argument(
          "--save_path",
          type=str,
          default="./output/",
          help="Directory to save model and log.",
      )
  
      self.basic_group.add_argument(
          "--init_from_ckpt",
          type=str,
          default=None,
          help="Directory to load the model.",
      )
  
      self.basic_group.add_argument(
          "--data_name",
          type=str,
          default="FB15k",
          choices=[
              "FB15k",
              "FB15k-237",
              "wn18",
              "WN18RR",
              "wikikg2",
              "wikikg90m",
          ],
          help="Dataset name.",
      )
  
      self.basic_group.add_argument(
          "--use_dict",
          type=bool,
          default=False,
          help="Use the dict to index the data.",
      )
  
      self.basic_group.add_argument(
          "--kv_mode",
          type=str,
          default="kv",
          help="The order of string names and ids in dictionary files. kv denotes entity_name/relation_name, id.",
      )
  
      self.basic_group.add_argument(
          "--batch_size",
          type=int,
          default=1000,
          help="Number of triplets in a batch for training.",
      )
  
      self.basic_group.add_argument(
          "--test_batch_size",
          type=int,
          default=16,
          help="Number of triplets in a batch for validation and test.",
      )
  
      self.basic_group.add_argument(
          "--neg_sample_size",
          type=int,
          default=1,
          help="Number of negative samples of each triplet for training.",
      )
  
      self.basic_group.add_argument(
          "--filter_eval",
          action="store_true",
          help="Filter out existing triplets from evaluation candidates.",
      )
  
      self.basic_group.add_argument(
          "--model_name",
          default="TransE",
          choices=[
              "TransE",
              "RotatE",
              "DistMult",
              "ComplEx",
              "QuatE",
              "OTE",
          ],
          help="Knowledge embedding method for training.",
      )
  
      self.basic_group.add_argument(
          "--embed_dim",
          type=int,
          default=200,
          help="Dimension of real entity and relation embeddings.",
      )
  
      self.basic_group.add_argument(
          "-rc",
          "--reg_coef",
          type=float,
          default=0,
          help="Coefficient of regularization.",
      )
  
      self.basic_group.add_argument(
          "--loss_type",
          default="Logsigmoid",
          choices=[
              "Hinge",
              "Logistic",
              "Logsigmoid",
              "BCE",
              "Softplus",
          ],
          help="Loss function of KGE Model.",
      )
  
      self.basic_group.add_argument(
          "--max_steps",
          type=int,
          default=2000000,
          help="Number of batches to train.",
      )
  
      self.basic_group.add_argument(
          "--lr",
          type=float,
          default=0.1,
          help="Learning rate to optimize model parameters.",
      )
  
      self.basic_group.add_argument(
          "--optimizer",
          type=str,
          default="adagrad",
          choices=["adam", "adagrad", "sgd"],
          help="Optimizer of model parameters.",
      )
  
      self.basic_group.add_argument(
          "--cpu_lr",
          type=float,
          default=0.1,
          help="Learning rate to optimize shared embeddings on CPU.",
      )
  
      self.basic_group.add_argument(
          "--cpu_optimizer",
          type=str,
          default="adagrad",
          choices=["sgd", "adagrad"],
          help="Optimizer of shared embeddings on CPU.",
      )
  
      self.basic_group.add_argument(
          "--mix_cpu_gpu",
          action="store_true",
          help="Use shared embeddings and store entity embeddings on CPU.",
      )
  
      self.basic_group.add_argument(
          "--async_update",
          action="store_true",
          help="Asynchronously update embeddings with gradients.",
      )
  
      self.basic_group.add_argument(
          "--valid",
          action="store_true",
          help="Evaluate the model on"
          " the validation set during training.",
      )
  
      self.basic_group.add_argument(
          "--test",
          action="store_true",
          help="Evaluate the model on "
          "the test set after the model is trained.",
      )
  
      self.data_group = self.add_argument_group("data optional")
  
      self.data_group.add_argument(
          "--task_name",
          type=str,
          default="KGE",
          help="Task identifier.",
      )
  
      self.data_group.add_argument(
          "--num_workers",
          type=int,
          default=0,
          help="Number of workers used to load batch data.",
      )
  
      self.data_group.add_argument(
          "--neg_sample_type",
          type=str,
          default="chunk",
          choices=["chunk", "full", "batch"],
          help='The type of negative sampling. \n"chunk": sampled from all '
          "entities; triplets are devided into several chunks and each "
          'chunk shares a group of negative samples.\n"full": sampled'
          ' from all entities.\n"batch": sampling from current batch.\n',
      )
  
      self.data_group.add_argument(
          "--neg_deg_sample",
          action="store_true",
          help="Use true heads or tails in negative sampling. See details in"
          "https://arxiv.org/abs/1902.10197.",
      )
  
      self.data_group.add_argument(
          "-adv",
          "--neg_adversarial_sampling",
          action="store_true",
          help="Use negative adversarial sampling, which weights "
          "negative samples with higher scores more.",
      )
  
      self.data_group.add_argument(
          "-a",
          "--adversarial_temperature",
          default=1.0,
          type=float,
          help="Temperature used for negative adversarial sampling.",
      )
  
      self.data_group.add_argument(
          "--filter_sample",
          action="store_true",
          help="Filter out existing triplets in negative samples.",
      )
  
      self.data_group.add_argument(
          "--valid_percent",
          type=float,
          default=1.0,
          help="Percent of used validation triplets.",
      )
  
      self.model_group = self.add_argument_group("model optional")
  
      self.model_group.add_argument(
          "--use_feature",
          action="store_true",
          help="Use features for training.",
      )
  
      self.model_group.add_argument(
          "-rt",
          "--reg_type",
          type=str,
          default="norm_er",
          choices=["norm_er", "norm_hrt"],
          help='Regularization type.\n"norm_er": compute norm of '
          'entities and relations seperately.\n"norm_hrt": '
          "compute norm of heads, relations and tails seperately.",
      )
  
      self.model_group.add_argument(
          "-rn",
          "--reg_norm",
          type=int,
          default=3,
          help="Order of regularization norm.",
      )
  
      self.model_group.add_argument(
          "--weighted_loss",
          action="store_true",
          help="Use weights of samples when computing loss. See details in"
          "https://arxiv.org/abs/1902.10197.",
      )
  
      self.model_group.add_argument(
          "-m",
          "--margin",
          type=float,
          default=1.0,
          help="Margin value in Hinge loss.",
      )
  
      self.model_group.add_argument(
          "-pw",
          "--pairwise",
          action="store_true",
          help="Compute pairwise loss of triplets and negative samples.",
      )
  
      self.opt_group = self.add_argument_group(
          "score function optional"
      )
      self.opt_group.add_argument(
          "-g",
          "--gamma",
          type=float,
          default=12.0,
          help="Margin value of triplet scores.",
      )
  
      self.opt_group.add_argument(
          "--ote_scale",
          type=int,
          default=0,
          choices=[0, 1, 2],
          help="Scale method in OTE. 0-None; 1-abs; 2-exp.",
      )
  
      self.opt_group.add_argument(
          "--ote_size",
          type=int,
          default=1,
          help="Number of linear transform matrix in OTE.",
      )
  
      self.opt_group.add_argument(
          "--quate_lmbda1",
          type=float,
          default=0.0,
          help="Coefficient of the first regularization in QuatE.",
      )
  
      self.opt_group.add_argument(
          "--quate_lmbda2",
          type=float,
          default=0.0,
          help="Coefficient of the second regularization in QuatE.",
      )
  
      self.train_group = self.add_argument_group("train optional")
      self.train_group.add_argument(
          "--num_epoch",
          type=int,
          default=1000000,
          help="Number of epochs to train.",
      )
  
      self.train_group.add_argument(
          "--scheduler_interval",
          type=int,
          default=-1,
          help="Interval size to update learning rate of model. -1 denotes constant.",
      )
  
      self.train_group.add_argument(
          "--num_process",
          type=int,
          default=1,
          help="Number of processes for asynchroneous gradient update.",
      )
  
      self.train_group.add_argument(
          "--print_on_screen",
          action="store_true",
          help="Print logs in console.",
      )
  
      self.train_group.add_argument(
          "-log",
          "--log_interval",
          type=int,
          default=1000,
          help="Print"
          " runtime of different components every x steps.",
      )
  
      self.train_group.add_argument(
          "--save_interval",
          type=int,
          default=-1,
          help="Interval size to save model checkpoint.",
      )
  
      self.train_group.add_argument(
          "--eval_interval",
          type=int,
          default=50000,
          help="Print "
          "evaluation results on the validation dataset every x steps.",
      )
  
file_path: PGL/apps/Graph4KG/config.py
imports: import os
  import sys
  import math
  import json
  import warnings
  from argparse import ArgumentParser
  import paddle.distributed
label_desc: Use image node_id 1 to create a new KGEArgParser object from inherited base classes: ArgumentParser with example: obj = KGEArgParser()