code: def _get_vpc_id_of_sg(
      sg_ids: List[str], config: Dict[str, Any]
  ) -> str:
      """Returns the VPC id of the security groups with the provided security
      group ids.
  
      Errors if the provided security groups belong to multiple VPCs.
      Errors if no security group with any of the provided ids is identified.
      """
      # sort security group IDs to support deterministic unit test stubbing
      sg_ids = sorted(set(sg_ids))
  
      ec2 = _resource("ec2", config)
      filters = [{"Name": "group-id", "Values": sg_ids}]
      security_groups = ec2.security_groups.filter(Filters=filters)
      vpc_ids = [sg.vpc_id for sg in security_groups]
      vpc_ids = list(set(vpc_ids))
  
      multiple_vpc_msg = (
          "All security groups specified in the cluster config "
          "should belong to the same VPC."
      )
      cli_logger.doassert(len(vpc_ids) <= 1, multiple_vpc_msg)
      assert len(vpc_ids) <= 1, multiple_vpc_msg
  
      no_sg_msg = (
          "Failed to detect a security group with id equal to any of "
          "the configured SecurityGroupIds."
      )
      cli_logger.doassert(len(vpc_ids) > 0, no_sg_msg)
      assert len(vpc_ids) > 0, no_sg_msg
  
      return vpc_ids[0]
  
imports: import copy
  import itertools
  import json
  import logging
  import os
  import time
  from collections import Counter
  from functools import lru_cache, partial
  from typing import Any, Dict, List, Optional, Set, Tuple
  import boto3
  import botocore
  from packaging.version import Version
  from ray.autoscaler._private.aws.cloudwatch.cloudwatch_helper import CloudwatchHelper
  from ray.autoscaler._private.aws.utils import LazyDefaultDict, handle_boto_error, resource_cache
  from ray.autoscaler._private.cli_logger import cf, cli_logger
  from ray.autoscaler._private.event_system import CreateClusterEvent, global_event_system
  from ray.autoscaler._private.providers import _PROVIDER_PRETTY_NAMES
  from ray.autoscaler._private.util import check_legacy_fields
  from ray.autoscaler.tags import NODE_TYPE_LEGACY_HEAD, NODE_TYPE_LEGACY_WORKER
label_desc: Use image node_id 13 for calling a global function with example usage: _get_vpc_id_of_sg(sg_ids, config) and returns: vpc_ids