code: def _configure_from_launch_template(
      config: Dict[str, Any]
  ) -> Dict[str, Any]:
      """
      Merges any launch template data referenced by the node config of all
      available node type's into their parent node config. Any parameters
      specified in node config override the same parameters in the launch
      template, in compliance with the behavior of the ec2.create_instances
      API.
  
      Args:
          config (Dict[str, Any]): config to bootstrap
      Returns:
          config (Dict[str, Any]): The input config with all launch template
          data merged into the node config of all available node types. If no
          launch template data is found, then the config is returned
          unchanged.
      Raises:
          ValueError: If no launch template is found for any launch
          template [name|id] and version, or more than one launch template is
          found.
      """
      # create a copy of the input config to modify
      config = copy.deepcopy(config)
      node_types = config["available_node_types"]
  
      # iterate over sorted node types to support deterministic unit test stubs
      for name, node_type in sorted(node_types.items()):
          node_types[name] = _configure_node_type_from_launch_template(
              config, node_type
          )
      return config
  
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 31 for calling a global function with example usage: _configure_from_launch_template(config) and returns: config