code: def _generate_available_node_types_from_ray_cr_spec(
      ray_cr_spec: Dict[str, Any]
  ) -> Dict[str, Any]:
      """Formats autoscaler "available_node_types" field based on the Ray CR's group
      specs.
      """
      headGroupSpec = ray_cr_spec["headGroupSpec"]
      return {
          _HEAD_GROUP_NAME: _node_type_from_group_spec(
              headGroupSpec, is_head=True
          ),
          **{
              worker_group_spec[
                  "groupName"
              ]: _node_type_from_group_spec(
                  worker_group_spec, is_head=False
              )
              for worker_group_spec in ray_cr_spec["workerGroupSpecs"]
          },
      }
  
imports: import decimal
  import json
  import logging
  import time
  from typing import Any, Dict, Optional
  import requests
  from ray.autoscaler._private.constants import DISABLE_LAUNCH_CONFIG_CHECK_KEY, DISABLE_NODE_UPDATERS_KEY, FOREGROUND_NODE_LAUNCH_KEY, WORKER_LIVENESS_CHECK_KEY, WORKER_RPC_DRAIN_KEY
  from ray.autoscaler._private.kuberay import node_provider, utils
  from ray.autoscaler._private.util import validate_config
label_desc: Use image node_id 4 for calling a global function with example usage: _generate_available_node_types_from_ray_cr_spec(ray_cr_spec) and returns: dict