code: def add_tags_to_aws_config(
      aws_config: dict, tags_to_add: dict, resource_types: list
  ):
      aws_config = deepcopy(aws_config)
      tag_specifications = aws_config.setdefault(
          "TagSpecifications", []
      )
  
      for resource in resource_types:
          # Check if there is already a tag specification for the resource.
          # If so, return first item.
          resource_tags: dict = next(
              (
                  x
                  for x in tag_specifications
                  if x.get("ResourceType", "") == resource
              ),
              None,
          )
  
          # If no tag specification exists, add
          if resource_tags is None:
              resource_tags = {"ResourceType": resource, "Tags": []}
              tag_specifications.append(resource_tags)
  
          # Add our tags to the specification
          tags = resource_tags["Tags"]
          for key, value in tags_to_add.items():
              tags.append({"Key": key, "Value": value})
  
      return aws_config
  
file_path: ray/release/ray_release/aws.py
imports: import os
  from copy import deepcopy
  from typing import Optional
  import boto3
  from botocore.exceptions import ClientError
  from ray_release.logger import logger
  from ray_release.util import DeferredEnvVar
label_desc: Use image node_id 3 for calling a global function with example usage: add_tags_to_aws_config(aws_config, tags_to_add, resource_types) and returns: aws_config