code: def instance_config_from_pool_config(
      pool_config: "PoolConfig",
      product_versions: ProductVersions,
      location: str,
  ) -> InstanceConfig:
      cloud = pool_config.cloud
      if cloud == "gcp":
          machine_type = family_worker_type_cores_to_gcp_machine_type(
              GCP_MACHINE_FAMILY,
              pool_config.worker_type,
              pool_config.worker_cores,
          )
          return GCPSlimInstanceConfig.create(
              product_versions=product_versions,
              machine_type=machine_type,
              preemptible=pool_config.preemptible,
              local_ssd_data_disk=pool_config.worker_local_ssd_data_disk,
              data_disk_size_gb=pool_config.data_disk_size_gb,
              boot_disk_size_gb=pool_config.boot_disk_size_gb,
              job_private=False,
              location=location,
          )
      assert cloud == "azure"
      machine_type = azure_worker_properties_to_machine_type(
          pool_config.worker_type,
          pool_config.worker_cores,
          pool_config.worker_local_ssd_data_disk,
      )
      return AzureSlimInstanceConfig.create(
          product_versions=product_versions,
          machine_type=machine_type,
          preemptible=pool_config.preemptible,
          local_ssd_data_disk=pool_config.worker_local_ssd_data_disk,
          data_disk_size_gb=pool_config.data_disk_size_gb,
          boot_disk_size_gb=pool_config.boot_disk_size_gb,
          job_private=False,
          location=location,
      )
  
imports: import asyncio
  import logging
  from typing import Dict, Optional, Tuple
  from gear import Database
  from .cloud.azure.instance_config import AzureSlimInstanceConfig
  from .cloud.azure.resource_utils import azure_worker_properties_to_machine_type
  from .cloud.gcp.instance_config import GCPSlimInstanceConfig
  from .cloud.gcp.resource_utils import GCP_MACHINE_FAMILY, family_worker_type_cores_to_gcp_machine_type
  from .cloud.resource_utils import adjust_cores_for_memory_request, adjust_cores_for_packability, cores_mcpu_to_memory_bytes, local_ssd_size, machine_type_to_worker_type_cores, requested_storage_bytes_to_actual_storage_gib, valid_machine_types
  from .cloud.utils import possible_cloud_locations
  from .driver.billing_manager import ProductVersionInfo, ProductVersions
  from .instance_config import InstanceConfig
label_desc: Use image node_id 1 for calling a global function with example usage: instance_config_from_pool_config(pool_config, product_versions, location) and returns: AzureSlimInstanceConfig, GCPSlimInstanceConfig