code: def install_torchserve(skip_ts_install, hw, ts_version, nightly):
      if skip_ts_install:
          return
  
      # git checkout branch if it is needed
      cmd = "git checkout master && git reset --hard && git clean -dffx . && git pull --rebase"
      execute(cmd, wait=True)
      print("successfully reset git")
  
      ts_install_cmd = None
      if ts_version.startswith("torchserve==") or ts_version.startswith(
          "torchserve-nightly=="
      ):
          ts_install_cmd = "pip install {}".format(ts_version)
      else:
          cmd = "git checkout {}".format(ts_version)
          execute(cmd, wait=True)
  
      # install_dependencies.py
      if hw == "gpu":
          cmd = "python ts_scripts/install_dependencies.py --environment dev --cuda cu121"
      elif hw == "neuronx":
          cmd = "python ts_scripts/install_dependencies.py --environment dev --neuronx"
      else:
          cmd = "python ts_scripts/install_dependencies.py --environment dev"
      if nightly:
          cmd += " --nightly_torch"
      execute(cmd, wait=True)
      print("successfully install install_dependencies.py")
  
      # install torchserve
      if ts_install_cmd is None:
          ts_install_cmd = "python ts_scripts/install_from_src.py"
      execute(ts_install_cmd, wait=True)
      print("successfully install torchserve")
  
imports: import argparse
  import datetime
  import os
  import shutil
  from subprocess import Popen
  import ruamel.yaml
  from utils import gen_md_report, gen_metrics_json, gen_model_config_json
label_desc: Use image node_id 3 for calling a global function with example usage: install_torchserve(skip_ts_install, hw, ts_version, nightly) without return types