code: def setup_mock_kubernetes_client(
      monkeypatch, jobs, pods, mock_job_base
  ):
      monkeypatch.setattr(
          kubernetes_asyncio.client,
          "BatchV1Api",
          lambda api_client: MockBatchV1Api(api_client, jobs),
      )
      monkeypatch.setattr(
          kubernetes_asyncio.client,
          "CoreV1Api",
          lambda api_client: MockCoreV1Api(api_client, pods),
      )
      monkeypatch.setattr(
          kubernetes_asyncio.utils,
          "create_from_dict",
          lambda _, yaml_objects, namespace: mock_create_from_dict(
              yaml_objects, jobs, mock_job_base
          ),
      )
      monkeypatch.setattr(
          kubernetes_monitor,
          "LaunchKubernetesMonitor",
          MagicMock(),
      )
  
      async def _mock_get_context_and_client(*args, **kwargs):
          return None, None
  
      monkeypatch.setattr(
          kubernetes_monitor,
          "get_kube_context_and_api_client",
          _mock_get_context_and_client,
      )
  
      async def mock_create_from_dict(jobd, jobs_dict, mock_status):
          name = jobd["metadata"].get("name")
          if not name:
              name = jobd["metadata"]["generateName"] + "testname"
              jobd["metadata"]["name"] = name
  
          metadata = MockDict(jobd["metadata"])
          metadata.labels = metadata.get("labels", {})
          metadata.labels["job-name"] = name  # assign name
          job_spec = MockDict(jobd["spec"])
          job_spec.backoff_limit = job_spec.get(
              "backoffLimit", 6
          )  # kube defaults
          job_spec.completions = job_spec.get("completions", 1)
          job_spec.parallelism = job_spec.get("parallelism", 1)
          job_spec.suspend = job_spec.get("suspend", False)
          pod_spec = MockDict(jobd["spec"]["template"]["spec"])
          pod_spec.restart_policy = pod_spec.get(
              "restartPolicy", "Never"
          )
          pod_spec.preemption_policy = pod_spec.get(
              "preemptionPolicy", "PreemptLowerPriority"
          )
          pod_spec.node_name = pod_spec.get("nodeName", None)
          pod_spec.node_selector = pod_spec.get("nodeSelector", {})
          pod_spec.containers = pod_spec.get("containers")
          for i, cont in enumerate(pod_spec.containers):
              pod_spec.containers[i] = MockDict(cont)
  
          job_spec.template = MockDict(
              {
                  "spec": pod_spec,
              }
          )
          mock_job = MockDict(
              {
                  "status": mock_status,
                  "spec": job_spec,
                  "metadata": MockDict(metadata),
              }
          )
          jobs_dict[name] = mock_job
          return [mock_job]
  
file_path: wandb/tests/pytest_tests/system_tests/test_launch/test_launch_kubernetes.py
imports: from unittest.mock import MagicMock
  import kubernetes_asyncio
  import pytest
  from wandb.apis.internal import Api
  from wandb.sdk.launch import loader
  from wandb.sdk.launch.runner import kubernetes_monitor, kubernetes_runner
  from wandb.sdk.launch.utils import make_name_dns_safe
label_desc: Use image node_id 2 for calling a global function with example usage: setup_mock_kubernetes_client(monkeypatch, jobs, pods, mock_job_base) and returns: None,  None, list