code: def generate_model_and_weights(
      test_id: int,
      command: str,
      working_dir: Path,
      color_enum: Type[Union[Color, NoColor]] = Color,
      skip_missing_args: bool = False,
  ) -> None:
      print(
          f"{color_enum.LIGHT_CYAN}id: {test_id}, command: {command}{color_enum.ENDC}"
      )
      vw = try_get_workspace_or_none(
          cli=command,
          quiet=True,
          color_enum=color_enum,
          skip_missing_args=skip_missing_args,
      )
      if vw is None:
          return
      weights_dir = working_dir / "test_weights"
      weights_dir.mkdir(parents=True, exist_ok=True)
      with open(
          weights_dir / f"weights_{test_id}.json", "w"
      ) as weights_file:
          try:
              weights_file.write(vw.json_weights())
          except:
              print(
                  f"{color_enum.LIGHT_PURPLE}Weights could not be generated as base learner is KSVM{color_enum.ENDC}"
              )
      test_models_dir = working_dir / "test_models"
      test_models_dir.mkdir(parents=True, exist_ok=True)
      vw.save(str(test_models_dir / f"model_{test_id}.vw"))
      vw.finish()
  
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 3 for calling a global function with example usage: generate_model_and_weights(test_id, command, working_dir, color_enum, skip_missing_args) without return types