code: def gen_script(user_cfg_dict):
      file_current_dir = Path(__file__).resolve().parent
      template_filename = file_current_dir / "nodepred-ns.jinja-py"
      with open(template_filename, "r") as f:
          template = Template(f.read())
      pipeline_cfg = NodepredNSPipelineCfg(
          **user_cfg_dict["general_pipeline"]
      )
  
      if "num_layers" in user_cfg_dict["model"]:
          assert user_cfg_dict["model"]["num_layers"] == len(
              user_cfg_dict["general_pipeline"]["sampler"]["fan_out"]
          ), "The num_layers in model config should be the same as the length of fan_out in sampler. For example, if num_layers is 1, the fan_out cannot be [5, 10]"
  
      render_cfg = copy.deepcopy(user_cfg_dict)
      model_code = NodeModelFactory.get_source_code(
          user_cfg_dict["model"]["name"]
      )
      render_cfg["model_code"] = model_code
      render_cfg[
          "model_class_name"
      ] = NodeModelFactory.get_model_class_name(
          user_cfg_dict["model"]["name"]
      )
      render_cfg.update(
          DataFactory.get_generated_code_dict(
              user_cfg_dict["data"]["name"], '**cfg["data"]'
          )
      )
      generated_user_cfg = copy.deepcopy(user_cfg_dict)
  
      if "split_ratio" in generated_user_cfg["data"]:
          generated_user_cfg["data"].pop("split_ratio")
      generated_user_cfg["data_name"] = generated_user_cfg["data"].pop(
          "name"
      )
      generated_user_cfg.pop("pipeline_name")
      generated_user_cfg.pop("pipeline_mode")
      generated_user_cfg["model_name"] = generated_user_cfg[
          "model"
      ].pop("name")
      generated_user_cfg["general_pipeline"]["optimizer"].pop("name")
  
      if user_cfg_dict["data"].get("split_ratio", None) is not None:
          render_cfg[
              "data_initialize_code"
          ] = "{}, split_ratio={}".format(
              render_cfg["data_initialize_code"],
              user_cfg_dict["data"]["split_ratio"],
          )
  
      render_cfg["user_cfg_str"] = f"cfg = {str(generated_user_cfg)}"
      render_cfg["user_cfg"] = user_cfg_dict
      with open("output.py", "w") as f:
          return template.render(**render_cfg)
  
imports: import copy
  from enum import Enum
  from pathlib import Path
  from typing import List, Optional, Union
  import ruamel.yaml
  import typer
  import yaml
  from jinja2 import ext, Template
  from pydantic import BaseModel, Field
  from ruamel.yaml.comments import CommentedMap
  from typing_extensions import Literal
  from ...utils.base_model import DeviceEnum, EarlyStopConfig, extract_name
  from ...utils.factory import DataFactory, NodeModelFactory, PipelineBase, PipelineFactory
  from ...utils.yaml_dump import deep_convert_dict, merge_comment
label_desc: Use image node_id 5 for calling the NodepredNsPipeline obj's underlying member method code with example usage: obj.gen_script(user_cfg_dict) and returns: template