code: def test_get_num_cpus(
      in_k8s: bool,
      env_disable: bool,
      override_disable: bool,
      got_docker_cpus: bool,
      monkeypatch,
  ):
      """Tests
      - Conditions under which ray._private.utils.get_num_cpus logs a warning about
          docker.
      - Fallback to multiprocessing.cpu_count if there's no docker count available.
      """
      # Shouldn't get the log warning if we're in K8s, the env variable is set,
      # the flag arg to get_num_cpus is set, or getting docker cpus fails.
      # Otherwise, should get the log message.
      should_not_log = any(
          [in_k8s, env_disable, override_disable, not got_docker_cpus]
      )
      expected_warning = (
          "Detecting docker specified CPUs. In "
          "previous versions of Ray, CPU detection in containers "
          "was incorrect. Please ensure that Ray has enough CPUs "
          "allocated. As a temporary workaround to revert to the "
          "prior behavior, set "
          "`RAY_USE_MULTIPROCESSING_CPU_COUNT=1` as an env var "
          "before starting Ray. Set the env var: "
          "`RAY_DISABLE_DOCKER_CPU_WARNING=1` to mute this warning."
      )
      if got_docker_cpus:
          mock_get_docker_cpus = mock.Mock(return_value=128)
      else:
          mock_get_docker_cpus = mock.Mock(side_effect=Exception())
  
      if in_k8s:
          monkeypatch.setenv("KUBERNETES_SERVICE_HOST", 1)
      else:
          try:
              monkeypatch.delenv("KUBERNETES_SERVICE_HOST")
          except KeyError:
              pass
  
      with mock.patch.multiple(
          "ray._private.utils",
          _get_docker_cpus=mock_get_docker_cpus,
          ENV_DISABLE_DOCKER_CPU_WARNING=env_disable,
          logger=mock.DEFAULT,
      ) as mocks:
          num_cpus = ray._private.utils.get_num_cpus(override_disable)
  
          if got_docker_cpus:
              # Got the docker count of 128 CPUs in the giant mock container.
              assert num_cpus == 128
          else:
              # Failed to get docker count and fell back to multiprocessing count.
              assert num_cpus == multiprocessing.cpu_count()
  
          if should_not_log:
              mocks["logger"].warning.assert_not_called()
          else:
              mocks["logger"].warning.assert_called_with(
                  expected_warning
              )
  
imports: import glob
  import logging
  import multiprocessing
  import os
  import sys
  import tempfile
  import time
  from unittest import mock
  import numpy
  import psutil
  import pytest
  import ray
  import ray._private.gcs_utils
  import ray._private.ray_constants
  import ray._private.utils
  import ray.cluster_utils
  import ray.util.accelerators
  from ray._private.test_utils import wait_for_condition
  from ray.dashboard import k8s_utils
  from ray.runtime_env import RuntimeEnv
label_desc: Use image node_id 9 for calling a global function with example usage: test_get_num_cpus(in_k8s, env_disable, override_disable, got_docker_cpus, monkeypatch) without return types