code: def test_apportion_ports_bad():
      with pytest.raises(ValueError, match="Not enough ports in range"):
          _apportion_ports("100:102", None, 4, False)
      with pytest.raises(ValueError, match="Not enough ports in range"):
          _apportion_ports(None, "100:102", 4, False)
      with pytest.raises(ValueError, match="Not enough ports in range"):
          _apportion_ports("100:102", "100:102", 3, True)
      with pytest.raises(ValueError, match="Not enough ports in range"):
          _apportion_ports("100:102", "102:104", 3, True)
      with pytest.raises(
          ValueError, match="port_stop must be greater than port_start"
      ):
          _apportion_ports("102:100", None, 4, False)
      with pytest.raises(ValueError, match="invalid literal for int"):
          _apportion_ports("foo", None, 1, False)
      with pytest.raises(ValueError, match="too many values to unpack"):
          _apportion_ports("100:101:102", None, 1, False)
  
imports: from __future__ import annotations
  import asyncio
  import os
  import signal
  import subprocess
  import sys
  from multiprocessing import cpu_count
  from time import sleep
  import pytest
  from click.testing import CliRunner
  from dask.utils import tmpfile
  from distributed import Client
  from distributed.cli.dask_worker import _apportion_ports, main
  from distributed.compatibility import LINUX, WINDOWS
  from distributed.deploy.utils import nprocesses_nthreads
  from distributed.metrics import time
  from distributed.utils import open_port
  from distributed.utils_test import gen_cluster, inc, popen, requires_ipv6, wait_for_log_line
label_desc: Use image node_id 2 for calling a global function with example usage: test_apportion_ports_bad() without return types