code: def test_target_duration(target_duration):
      @gen_test()
      async def _test():
          with dask.config.set(
              {
                  "distributed.scheduler.default-task-durations": {
                      "slowinc": 1
                  },
                  # adaptive target for queued tasks doesn't yet consider default or learned task durations
                  "distributed.scheduler.worker-saturation": float(
                      "inf"
                  ),
              }
          ):
              async with LocalCluster(
                  n_workers=0,
                  asynchronous=True,
                  processes=False,
                  silence_logs=False,
                  dashboard_address=":0",
              ) as cluster:
                  adapt = cluster.adapt(
                      interval="20ms",
                      minimum=2,
                      target_duration=target_duration,
                  )
                  # FIXME: LocalCluster is starting workers with CPU_COUNT threads
                  # each
                  # The default target duration is set to 1s
                  max_scaleup = 5
                  n_tasks = (
                      target_duration
                      * dask.system.CPU_COUNT
                      * max_scaleup
                  )
  
                  async with Client(
                      cluster, asynchronous=True
                  ) as client:
                      await client.wait_for_workers(2)
                      futures = client.map(
                          slowinc, range(n_tasks), delay=0.3
                      )
                      await wait(futures)
                  scaleup_recs = [
                      msg[1]["n"]
                      for msg in adapt.log
                      if msg[1].get("status") == "up"
                  ]
  
                  assert (
                      2
                      <= min(scaleup_recs)
                      < max(scaleup_recs)
                      <= max_scaleup
                  )
  
      _test()
  
file_path: distributed/distributed/deploy/tests/test_adaptive.py
imports: from __future__ import annotations
  import asyncio
  import math
  from time import sleep
  import pytest
  import dask
  from distributed import Adaptive, Client, LocalCluster, Scheduler, SpecCluster, Worker, wait
  from distributed.metrics import time
  from distributed.utils_test import async_poll_for, gen_cluster, gen_test, slowinc
label_desc: Use image node_id 3 for calling a global function with example usage: test_target_duration(target_duration) without return types