code: def test_default_cpu_strategy(monkeypatch: MonkeyPatch):
      monkeypatch.setattr(
          strategy, "get_resource", unvalidated_get_resource
      )
      assert (
          DefaultStrategy.get_worker_count(
              SingleThreadRunnable, {"cpu": 2}, 1
          )
          == 2
      )
      assert (
          DefaultStrategy.get_worker_count(
              SingleThreadRunnable, {"cpu": 0.5}, 1
          )
          == 1
      )
      assert (
          DefaultStrategy.get_worker_count(
              SingleThreadRunnable, {"cpu": 2}, 2
          )
          == 4
      )
      assert (
          DefaultStrategy.get_worker_count(
              MultiThreadRunnable, {"cpu": 4}, 1
          )
          == 1
      )
      assert (
          DefaultStrategy.get_worker_count(
              MultiThreadRunnable, {"cpu": 4}, 2
          )
          == 2
      )
  
      envs = DefaultStrategy.get_worker_env(
          SingleThreadRunnable, {"cpu": 4}, 1, 0
      )
      assert envs["CUDA_VISIBLE_DEVICES"] == "-1"
      assert envs["BENTOML_NUM_THREAD"] == "1"
  
      envs = DefaultStrategy.get_worker_env(
          SingleThreadRunnable, {"cpu": 4}, 1, 1
      )
      assert envs["BENTOML_NUM_THREAD"] == "1"
  
      envs = DefaultStrategy.get_worker_env(
          MultiThreadRunnable, {"cpu": 4}, 1, 0
      )
      assert envs["BENTOML_NUM_THREAD"] == "4"
      envs = DefaultStrategy.get_worker_env(
          MultiThreadRunnable, {"cpu": 3.5}, 1, 1
      )
      assert envs["BENTOML_NUM_THREAD"] == "4"
  
file_path: BentoML/tests/unit/_internal/runner/test_strategy.py
imports: from __future__ import annotations
  import typing
  import pytest
  import bentoml
  from bentoml._internal.resource import get_resource
  from bentoml._internal.runner import strategy
  from bentoml._internal.runner.strategy import DefaultStrategy
label_desc: Use image node_id 3 for calling a global function with example usage: test_default_cpu_strategy(monkeypatch) without return types