code: def test_target_capacity_field(ray_start_stop, url: str):
      """Test that the `target_capacity` field is always populated as expected."""
  
      raw_json = requests.get(url).json()
  
      # `target_capacity` should be present in the response before deploying anything.
      assert raw_json["target_capacity"] is None
  
      config = {
          "http_options": {
              "host": "127.0.0.1",
              "port": 8000,
          },
          "applications": [],
      }
      deploy_config_multi_app(config, url)
  
      # `target_capacity` should be present in the response even if not set.
      raw_json = requests.get(url).json()
      assert raw_json["target_capacity"] is None
      details = ServeInstanceDetails(**raw_json)
      assert details.target_capacity is None
      assert details.http_options.host == "127.0.0.1"
      assert details.http_options.port == 8000
      assert details.applications == {}
  
      # Set `target_capacity`, ensure it is returned properly.
      config["target_capacity"] = 20
      deploy_config_multi_app(config, url)
      raw_json = requests.get(url).json()
      assert raw_json["target_capacity"] == 20
      details = ServeInstanceDetails(**raw_json)
      assert details.target_capacity == 20
      assert details.http_options.host == "127.0.0.1"
      assert details.http_options.port == 8000
      assert details.applications == {}
  
      # Update `target_capacity`, ensure it is returned properly.
      config["target_capacity"] = 40
      deploy_config_multi_app(config, url)
      raw_json = requests.get(url).json()
      assert raw_json["target_capacity"] == 40
      details = ServeInstanceDetails(**raw_json)
      assert details.target_capacity == 40
      assert details.http_options.host == "127.0.0.1"
      assert details.http_options.port == 8000
      assert details.applications == {}
  
      # Reset `target_capacity` by omitting it, ensure it is returned properly.
      del config["target_capacity"]
      deploy_config_multi_app(config, url)
      raw_json = requests.get(url).json()
      assert raw_json["target_capacity"] is None
      details = ServeInstanceDetails(**raw_json)
      assert details.target_capacity is None
      assert details.http_options.host == "127.0.0.1"
      assert details.http_options.port == 8000
      assert details.applications == {}
  
      # Try to set an invalid `target_capacity`, ensure a `400` status is returned.
      config["target_capacity"] = 101
      assert (
          requests.put(url, json=config, timeout=30).status_code == 400
      )
  
imports: import copy
  import grpc
  import re
  import os
  import sys
  from typing import Dict
  import pytest
  import requests
  import ray
  from ray import serve
  from ray._private.test_utils import wait_for_condition
  import ray._private.ray_constants
  from ray.util.state import list_actors
  from ray.serve._private.constants import SERVE_NAMESPACE
  from ray.serve.tests.conftest import *
  from ray.tests.conftest import *
  from ray._private.test_utils import generate_system_config_map
  from ray.serve.schema import ServeInstanceDetails, HTTPOptionsSchema
  from ray.serve._private.common import ApplicationStatus, DeploymentStatus, DeploymentStatusTrigger, ReplicaState, ProxyStatus
  from ray.serve.generated import serve_pb2, serve_pb2_grpc
label_desc: Use image node_id 14 for calling a global function with example usage: test_target_capacity_field(ray_start_stop, url) without return types