code: def test_create_sg_different_vpc_same_rules(
      iam_client_stub, ec2_client_stub, correct_az: bool
  ):
      # use default stubs to skip ahead to security group configuration
      stubs.skip_to_configure_sg(ec2_client_stub, iam_client_stub)
  
      default_subnet = copy.deepcopy(DEFAULT_SUBNET)
      if not correct_az:
          default_subnet["AvailabilityZone"] = "us-west-2b"
  
      # given head and worker nodes with custom subnets defined...
      # expect to second describe the head subnet ID
      stubs.describe_subnets_echo(ec2_client_stub, [default_subnet])
      # expect to first describe the worker subnet ID
      stubs.describe_subnets_echo(ec2_client_stub, [AUX_SUBNET])
      # given no existing security groups within the VPC...
      stubs.describe_no_security_groups(ec2_client_stub)
      # expect to first create a security group on the worker node VPC
      stubs.create_sg_echo(ec2_client_stub, DEFAULT_SG_AUX_SUBNET)
      # expect new worker security group details to be retrieved after creation
      stubs.describe_sgs_on_vpc(
          ec2_client_stub,
          [AUX_SUBNET["VpcId"]],
          [DEFAULT_SG_AUX_SUBNET],
      )
      # expect to second create a security group on the head node VPC
      stubs.create_sg_echo(ec2_client_stub, DEFAULT_SG)
      # expect new head security group details to be retrieved after creation
      stubs.describe_sgs_on_vpc(
          ec2_client_stub,
          [DEFAULT_SUBNET["VpcId"]],
          [DEFAULT_SG],
      )
  
      # given no existing default head security group inbound rules...
      # expect to authorize all default head inbound rules
      stubs.authorize_sg_ingress(
          ec2_client_stub,
          DEFAULT_SG_DUAL_GROUP_RULES,
      )
      # given no existing default worker security group inbound rules...
      # expect to authorize all default worker inbound rules
      stubs.authorize_sg_ingress(
          ec2_client_stub,
          DEFAULT_SG_WITH_RULES_AUX_SUBNET,
      )
  
      # given our mocks and an example config file as input...
      # expect the config to be loaded, validated, and bootstrapped successfully
      error = None
      try:
          config = helpers.bootstrap_aws_example_config_file(
              "example-subnets.yaml"
          )
      except ClickException as e:
          error = e
  
      _get_subnets_or_die.cache_clear()
  
      if not correct_az:
          assert isinstance(
              error, ClickException
          ), "Did not get a ClickException!"
          iam_client_stub._queue.clear()
          ec2_client_stub._queue.clear()
          return
  
      # expect the bootstrapped config to show different head and worker security
      # groups residing on different subnets
      for node_type_key, node_type in config[
          "available_node_types"
      ].items():
          node_config = node_type["node_config"]
          security_group_ids = node_config["SecurityGroupIds"]
          subnet_ids = node_config["SubnetIds"]
          if node_type_key == config["head_node_type"]:
              assert security_group_ids == [DEFAULT_SG["GroupId"]]
              assert subnet_ids == [DEFAULT_SUBNET["SubnetId"]]
          else:
              assert security_group_ids == [AUX_SG["GroupId"]]
              assert subnet_ids == [AUX_SUBNET["SubnetId"]]
  
      # expect no pending responses left in IAM or EC2 client stub queues
      iam_client_stub.assert_no_pending_responses()
      ec2_client_stub.assert_no_pending_responses()
  
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 2 for calling a global function with example usage: test_create_sg_different_vpc_same_rules(iam_client_stub, ec2_client_stub, correct_az) without return types