code: def test_launch_template_vars(
      command_inputs, expected_error, runner, monkeypatch
  ):
      mock_template_variables = [
          {
              "name": "test_str",
              "schema": json.dumps({"type": "string"}),
          },
          {
              "name": "test_int",
              "schema": json.dumps({"type": "integer"}),
          },
          {
              "name": "test_num",
              "schema": json.dumps({"type": "number"}),
          },
      ]
      expected_template_variables = {
          "test_str": "str1",
          "test_int": 2,
          "test_num": 2.5,
      }
  
      async def patched_launch_add(*args, **kwargs):
          # Assert template variables are as expected
          if (
              not isinstance(args[4], dict)
              or args[4] != expected_template_variables
          ):
              raise Exception(args)
  
      monkeypatch.setattr(
          "wandb.cli.cli._launch_add",
          patched_launch_add,
      )
  
      def patched_public_api(*args, **kwargs):
          return Mock()
  
      monkeypatch.setattr(
          "wandb.cli.cli.PublicApi",
          patched_public_api,
      )
  
      monkeypatch.setattr(
          "wandb.cli.cli.launch_utils.check_logged_in", lambda _: None
      )
  
      def patched_run_queue(*args, **kwargs):
          mock_rq = Mock()
          mock_rq.template_variables = mock_template_variables
          mock_rq.name = "test-queue"
          return mock_rq
  
      monkeypatch.setattr(
          "wandb.cli.cli.RunQueue",
          patched_run_queue,
      )
  
      result = "none"
      with runner.isolated_filesystem():
          result = runner.invoke(
              cli.launch, command_inputs, catch_exceptions=False
          )
      if expected_error:
          assert expected_error in result.output
          assert result.exit_code == 1
      else:
          assert result.exit_code == 0
  
imports: import json
  from unittest.mock import Mock
  import pytest
  import wandb
  from wandb.cli import cli
  from wandb.sdk.launch.errors import LaunchError
label_desc: Use image node_id 17 for calling a global function with example usage: test_launch_template_vars(command_inputs, expected_error, runner, monkeypatch) and returns: Mock, mock_rq