code: def resource_dict_to_pg_factory(
      spec: Optional[Dict[str, float]] = None
  ):
      """Translates resource dict into PlacementGroupFactory."""
      spec = spec or {"cpu": 1}
  
      spec = spec.copy()
  
      cpus = spec.pop("cpu", spec.pop("CPU", 0.0))
      gpus = spec.pop("gpu", spec.pop("GPU", 0.0))
      memory = spec.pop("memory", 0.0)
  
      # If there is a custom_resources key, use as base for bundle
      bundle = {
          k: v for k, v in spec.pop("custom_resources", {}).items()
      }
  
      # Otherwise, consider all other keys as custom resources
      if not bundle:
          bundle = spec
  
      bundle.update(
          {
              "CPU": cpus,
              "GPU": gpus,
              "memory": memory,
          }
      )
  
      return PlacementGroupFactory([bundle])
  
file_path: ray/python/ray/tune/execution/placement_groups.py
imports: import warnings
  from typing import Dict, Optional
  from ray.air.execution.resources.request import ResourceRequest
  from ray.util.annotations import DeveloperAPI, PublicAPI
  from ray.util.placement_group import placement_group
label_desc: Use image node_id 1 for calling a global function with example usage: resource_dict_to_pg_factory(spec) and returns: PlacementGroupFactory