code: def gen_script(cls, user_cfg_dict):
      cls.setup_user_cfg_cls()
      # Check validation
      user_cfg = cls.user_cfg_cls(**user_cfg_dict)
      file_current_dir = Path(__file__).resolve().parent
      with open(file_current_dir / "linkpred.jinja-py", "r") as f:
          template = Template(f.read())
  
      render_cfg = copy.deepcopy(user_cfg_dict)
      render_cfg["node_model_code"] = NodeModelFactory.get_source_code(
          user_cfg_dict["node_model"]["name"]
      )
      render_cfg["edge_model_code"] = EdgeModelFactory.get_source_code(
          user_cfg_dict["edge_model"]["name"]
      )
      render_cfg[
          "node_model_class_name"
      ] = NodeModelFactory.get_model_class_name(
          user_cfg_dict["node_model"]["name"]
      )
      render_cfg[
          "edge_model_class_name"
      ] = EdgeModelFactory.get_model_class_name(
          user_cfg_dict["edge_model"]["name"]
      )
      render_cfg[
          "neg_sampler_name"
      ] = NegativeSamplerFactory.get_model_class_name(
          user_cfg_dict["neg_sampler"]["name"]
      )
      render_cfg["loss"] = user_cfg_dict["general_pipeline"]["loss"]
      # update import and initialization code
      render_cfg.update(
          DataFactory.get_generated_code_dict(
              user_cfg_dict["data"]["name"], '**cfg["data"]'
          )
      )
      generated_user_cfg = copy.deepcopy(user_cfg_dict)
      if len(generated_user_cfg["data"]) == 1:
          generated_user_cfg.pop("data")
      else:
          generated_user_cfg["data"].pop("name")
      generated_user_cfg.pop("pipeline_name")
      generated_user_cfg.pop("pipeline_mode")
      generated_user_cfg["node_model"].pop("name")
      generated_user_cfg["edge_model"].pop("name")
      generated_user_cfg["neg_sampler"].pop("name")
      generated_user_cfg["general_pipeline"]["optimizer"].pop("name")
      generated_user_cfg["general_pipeline"].pop("loss")
      generated_train_cfg = copy.deepcopy(
          user_cfg_dict["general_pipeline"]
      )
      generated_train_cfg["optimizer"].pop("name")
  
      if user_cfg_dict["data"].get("split_ratio", None) is not None:
          assert (
              user_cfg_dict["data"].get("neg_ratio", None) is not None
          ), "Please specify both split_ratio and neg_ratio"
          render_cfg[
              "data_initialize_code"
          ] = "{}, split_ratio={}, neg_ratio={}".format(
              render_cfg["data_initialize_code"],
              user_cfg_dict["data"]["split_ratio"],
              user_cfg_dict["data"]["neg_ratio"],
          )
          generated_user_cfg["data"].pop("split_ratio")
          generated_user_cfg["data"].pop("neg_ratio")
  
      render_cfg["user_cfg_str"] = f"cfg = {str(generated_user_cfg)}"
      render_cfg["user_cfg"] = user_cfg_dict
      return template.render(**render_cfg)
  
imports: import copy
  from pathlib import Path
  from typing import Optional
  import ruamel.yaml
  import typer
  import yaml
  from jinja2 import Template
  from pydantic import BaseModel, Field
  from ruamel.yaml.comments import CommentedMap
  from ...utils.base_model import DeviceEnum, EarlyStopConfig
  from ...utils.factory import DataFactory, EdgeModelFactory, NegativeSamplerFactory, NodeModelFactory, PipelineBase, PipelineFactory
  from ...utils.yaml_dump import deep_convert_dict, merge_comment
label_desc: Use image node_id 5 for calling the LinkpredPipeline obj's underlying member method code with example usage: obj.gen_script(cls, user_cfg_dict) and returns: template