code: def load_model(
      test_id: int,
      command: str,
      working_dir: Path,
      color_enum: Type[Union[Color, NoColor]] = Color,
      skip_missing_args: bool = False,
  ) -> None:
      model_file = str(
          working_dir / "test_models" / f"model_{test_id}.vw"
      )
      if not os.path.isfile(model_file):
          print(
              f"{color_enum.LIGHT_CYAN}Model file [{model_file}] is not present, skipping this test{color_enum.ENDC}"
          )
          return
      load_command = f" -i {model_file}"
  
      # Some options must be manually kept when loading a model
      keep_commands = [
          "--simulation",
          "--eval",
          "--compete",
          "--cbify_reg",
          "--sparse_weights",
      ]
      for k in keep_commands:
          if k in command:
              load_command += f" {k}"
  
      # Some options with one arg must be manually kept
      keep_arg_commands = [
          "--dictionary_path",
          "--loss_function",
      ]
      for k in keep_arg_commands:
          cmd_split = command.split(" ")
          for i, v in enumerate(cmd_split):
              if v == k:
                  load_command += f" {v} {cmd_split[i + 1]}"
  
      print(
          f"{color_enum.LIGHT_PURPLE}id: {test_id}, command: {load_command}{color_enum.ENDC}"
      )
  
      try:
          vw = try_get_workspace_or_none(
              cli=load_command,
              quiet=True,
              color_enum=color_enum,
              skip_missing_args=skip_missing_args,
          )
          if vw is None:
              return
          try:
              new_weights = json.loads(vw.json_weights())
          except:
              print(
                  f"{color_enum.LIGHT_CYAN}Weights could not be loaded as base learner is KSVM{color_enum.ENDC}"
              )
              return
          weights_dir = working_dir / "test_weights"
          weights_dir.mkdir(parents=True, exist_ok=True)
          weight_file = str(weights_dir / f"weights_{test_id}.json")
  
          # Load old weights
          old_weights = json.load(open(weight_file))
  
          # Sort the weights inside both dictionaries based on 'index'
          new_weights["weights"].sort(key=lambda x: x["index"])
          old_weights["weights"].sort(key=lambda x: x["index"])
  
          # Assert if both sorted weights are equal
          assert new_weights == old_weights
          vw.finish()
      except Exception as e:
          print(
              f"{color_enum.LIGHT_RED} FAILURE!! id: {test_id} {str(e)}"
          )
          raise e
  
file_path: vowpal_wabbit/test/run_tests_model_gen_and_load.py
imports: import argparse
  from genericpath import isdir, isfile
  from pathlib import Path
  import re
  import os
  import shutil
  import json
  from run_tests import convert_to_test_data, Color, NoColor, TestData
  import vowpalwabbit
  from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Type, Union, cast
label_desc: Use image node_id 4 for calling a global function with example usage: load_model(test_id, command, working_dir, color_enum, skip_missing_args) without return types