code: def allocate_experiment_resources(resources: Resources) -> dict:
      """Allocates ray trial resources based on available resources.
  
      # Inputs
      :param resources (dict) specifies all available GPUs, CPUs and associated
          metadata of the machines (i.e. memory)
  
      # Return
      :return: (dict) gpu and cpu resources per trial
      """
      # TODO (ASN):
      # (1) expand logic to support multiple GPUs per trial (multi-gpu training)
      # (2) add support for kubernetes namespace (if applicable)
      # (3) add support for smarter allocation based on size of GPU memory
      experiment_resources = {"cpu_resources_per_trial": 1}
      gpu_count, cpu_count = resources.gpus, resources.cpus
      if gpu_count > 0:
          experiment_resources.update({"gpu_resources_per_trial": 1})
          if cpu_count > 1:
              cpus_per_trial = max(int(cpu_count / gpu_count), 1)
              experiment_resources[
                  "cpu_resources_per_trial"
              ] = cpus_per_trial
  
      return experiment_resources
  
imports: import logging
  import os
  from dataclasses import dataclass
  from typing import Any, Dict, List, Set, Union
  import dask.dataframe
  import numpy
  import pandas
  import yaml
  from dataclasses_json import dataclass_json, LetterCase
  from tqdm import tqdm
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.backend import Backend
  from ludwig.constants import COLUMN, COMBINER, ENCODER, EXECUTOR, HYPEROPT, INPUT_FEATURES, PREPROCESSING, SCHEDULER, SEARCH_ALG, SPLIT, TEXT, TYPE
  from ludwig.types import ModelConfigDict
  from ludwig.utils.automl.data_source import DataSource, wrap_data_source
  from ludwig.utils.automl.field_info import FieldConfig, FieldInfo, FieldMetadata
  from ludwig.utils.automl.type_inference import infer_type, should_exclude
  from ludwig.utils.data_utils import load_yaml
  from ludwig.utils.misc_utils import merge_dict
  from ludwig.utils.system_utils import Resources
label_desc: Use image node_id 1 for calling a global function with example usage: allocate_experiment_resources(resources) and returns: experiment_resources