code: def test_sanity():
      generate_grpc_client_stubs()
  
      print("## Started sanity tests")
  
      models_to_validate = load_model_to_validate()
  
      test_gpu_setup()
  
      ts_log_file = os.path.join("logs", "ts_console.log")
  
      os.makedirs("model_store", exist_ok=True)
      os.makedirs("logs", exist_ok=True)
  
      mg.mar_set = set(os.listdir("model_store"))
      started = ts.start_torchserve(log_file=ts_log_file, gen_mar=False)
      if not started:
          sys.exit(1)
  
      resnet18_model = models_to_validate["resnet-18"]
  
      models_to_validate = {
          k: v
          for k, v in models_to_validate.items()
          if k != "resnet-18"
      }
  
      for _, model in models_to_validate.items():
          run_grpc_test(model)
          run_rest_test(model)
  
      run_rest_test(resnet18_model, unregister_model=False)
  
      stopped = ts.stop_torchserve()
      if not stopped:
          sys.exit(1)
  
      # Restarting torchserve
      # This should restart with the generated snapshot and resnet-18 model should be automatically registered
      started = ts.start_torchserve(log_file=ts_log_file, gen_mar=False)
      if not started:
          sys.exit(1)
  
      run_rest_test(resnet18_model, register_model=False)
  
      stopped = ts.stop_torchserve()
      if not stopped:
          sys.exit(1)
  
file_path: serve/ts_scripts/sanity_utils.py
imports: import glob
  import json
  import os
  import subprocess
  import sys
  from pathlib import Path
  import torch
  from ts_scripts import marsgen
  from ts_scripts import tsutils
  from ts_scripts import utils
  from ts_scripts.tsutils import generate_grpc_client_stubs
label_desc: Use image node_id 7 for calling a global function with example usage: test_sanity() without return types