code: def get_cfg_func(self):
      def config(
          data: DataFactory.filter(
              "graphpred"
          ).get_dataset_enum() = typer.Option(
              None, help="input data name"
          ),
          cfg: Optional[str] = typer.Option(
              None, help="output configuration file path"
          ),
          cpt: str = typer.Option(
              ..., help="input checkpoint file path"
          ),
      ):
          # Training configuration
          train_cfg = torch.load(cpt)["cfg"]
          if data is None:
              print("data is not specified, use the training dataset")
              data = train_cfg["data_name"]
          else:
              data = data.name
          if cfg is None:
              cfg = (
                  "_".join(
                      [
                          "apply",
                          "graphpred",
                          data,
                          train_cfg["model_name"],
                      ]
                  )
                  + ".yaml"
              )
  
          self.__class__.setup_user_cfg_cls()
          generated_cfg = {
              "pipeline_name": self.pipeline["name"],
              "pipeline_mode": self.pipeline["mode"],
              "device": train_cfg["device"],
              "data": {"name": data},
              "cpt_path": cpt,
              "general_pipeline": {
                  "batch_size": train_cfg["general_pipeline"][
                      "eval_batch_size"
                  ],
                  "num_workers": train_cfg["general_pipeline"][
                      "num_workers"
                  ],
              },
          }
          output_cfg = self.user_cfg_cls(**generated_cfg).dict()
          output_cfg = deep_convert_dict(output_cfg)
          # Not applicable for inference
          output_cfg["data"].pop("split_ratio")
          comment_dict = {
              "device": "Torch device name, e.g., cpu or cuda or cuda:0",
              "cpt_path": "Path to the checkpoint file",
              "general_pipeline": pipeline_comments,
          }
          comment_dict = merge_comment(output_cfg, comment_dict)
  
          yaml = ruamel.yaml.YAML()
          yaml.dump(comment_dict, Path(cfg).open("w"))
          print(
              "Configuration file is generated at {}".format(
                  Path(cfg).absolute()
              )
          )
  
      return config
  
file_path: dgl/dglgo/dglgo/apply_pipeline/graphpred/gen.py
imports: from copy import deepcopy
  from pathlib import Path
  from typing import Optional
  import ruamel.yaml
  import torch
  import typer
  from jinja2 import Template
  from pydantic import BaseModel, Field
  from ...utils.factory import ApplyPipelineFactory, DataFactory, GraphModelFactory, PipelineBase
  from ...utils.yaml_dump import deep_convert_dict, merge_comment
label_desc: Use image node_id 4 for calling the ApplyGraphpredPipeline obj's underlying member method code with example usage: obj.get_cfg_func() and returns: config