code: def select_pool_from_cost(
      self, cloud, cores_mcpu, memory_bytes, storage_bytes, preemptible
  ):
      assert self.resource_rates is not None
  
      optimal_result = None
      optimal_cost = None
      for pool in self.name_pool_config.values():
          if pool.cloud != cloud or pool.preemptible != preemptible:
              continue
  
          result = pool.convert_requests_to_resources(
              cores_mcpu, memory_bytes, storage_bytes
          )
          if result:
              (
                  maybe_cores_mcpu,
                  maybe_memory_bytes,
                  maybe_storage_gib,
              ) = result
  
              max_regional_maybe_cost = None
              for location in possible_cloud_locations(pool.cloud):
                  maybe_cost = pool.cost_per_hour(
                      self.resource_rates,
                      self.product_versions,
                      location,
                      maybe_cores_mcpu,
                      maybe_memory_bytes,
                      maybe_storage_gib,
                  )
                  if (
                      max_regional_maybe_cost is None
                      or maybe_cost > max_regional_maybe_cost
                  ):
                      max_regional_maybe_cost = maybe_cost
  
              if optimal_cost is None or (
                  max_regional_maybe_cost is not None
                  and max_regional_maybe_cost < optimal_cost
              ):
                  optimal_cost = max_regional_maybe_cost
                  optimal_result = (
                      pool.name,
                      maybe_cores_mcpu,
                      maybe_memory_bytes,
                      maybe_storage_gib,
                  )
      return optimal_result
  
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 2 for calling the InstanceCollectionConfigs obj's underlying member method code with example usage: obj.select_pool_from_cost(cloud, cores_mcpu, memory_bytes, storage_bytes, preemptible) and returns: optimal_result