code: def test_use_subnets_ordered_by_az(ec2_client_stub):
      """
      This test validates that when bootstrap_aws populates the SubnetIds field,
      the subnets are ordered the same way as availability zones.
  
      """
      # Add a response with a twenty subnets round-robined across the 4 AZs in
      # `us-west-2` (a,b,c,d). At the end we should only have 15 subnets, ordered
      # first from `us-west-2c`, then `us-west-2d`, then `us-west-2a`.
      stubs.describe_twenty_subnets_in_different_azs(ec2_client_stub)
  
      base_config = helpers.load_aws_example_config_file(
          "example-full.yaml"
      )
      base_config["provider"][
          "availability_zone"
      ] = "us-west-2c,us-west-2d,us-west-2a"
      config = _configure_subnet(base_config)
  
      # We've filtered down to only subnets in 2c, 2d & 2a
      for node_type in config["available_node_types"].values():
          node_config = node_type["node_config"]
          assert len(node_config["SubnetIds"]) == 15
          offsets = [
              int(s.split("-")[1]) % 4 for s in node_config["SubnetIds"]
          ]
          assert set(offsets[:5]) == {
              2
          }, "First 5 should be in us-west-2c"
          assert set(offsets[5:10]) == {
              3
          }, "Next 5 should be in us-west-2d"
          assert set(offsets[10:15]) == {
              0
          }, "Last 5 should be in us-west-2a"
  
imports: import copy
  from unittest.mock import Mock, patch
  import pytest
  from click.exceptions import ClickException
  import ray.tests.aws.utils.helpers
  import ray.tests.aws.utils.stubs
  from ray.autoscaler._private.aws.config import DEFAULT_AMI, _configure_subnet, _get_subnets_or_die, bootstrap_aws, log_to_cli
  from ray.autoscaler._private.aws.node_provider import AWSNodeProvider
  from ray.autoscaler._private.providers import _get_node_provider
  from ray.tests.aws.utils.constants import AUX_SG, AUX_SUBNET, CUSTOM_IN_BOUND_RULES, DEFAULT_CLUSTER_NAME, DEFAULT_INSTANCE_PROFILE, DEFAULT_KEY_PAIR, DEFAULT_LT, DEFAULT_SG, DEFAULT_SG_AUX_SUBNET, DEFAULT_SG_DUAL_GROUP_RULES, DEFAULT_SG_WITH_NAME, DEFAULT_SG_WITH_NAME_AND_RULES, DEFAULT_SG_WITH_RULES, DEFAULT_SG_WITH_RULES_AUX_SUBNET, DEFAULT_SUBNET
label_desc: Use image node_id 16 for calling a global function with example usage: test_use_subnets_ordered_by_az(ec2_client_stub) without return types