code: def _get_num_gpus(
      ray_start_params: Dict[str, str],
      k8s_resource_limits: Dict[str, Any],
      group_name: str,
  ) -> Optional[int]:
      """Get memory resource annotation from ray_start_params or k8s_resource_limits,
      with priority for ray_start_params.
      """
  
      if "num-gpus" in ray_start_params:
          return int(ray_start_params["num-gpus"])
      else:
          for key in k8s_resource_limits:
              # e.g. nvidia.com/gpu
              if key.endswith("gpu"):
                  # Typically, this is a string representing an interger, e.g. "1".
                  gpu_resource_quantity = k8s_resource_limits[key]
                  # Convert to int, making no assumptions on the gpu_resource_quantity,
                  # besides that it's valid as a K8s resource quantity.
                  num_gpus = _round_up_k8s_quantity(
                      gpu_resource_quantity
                  )
                  if num_gpus > 0:
                      # Only one GPU type supported for now, break out on first
                      # "/gpu" match.
                      return num_gpus
      return None
  
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 9 for calling a global function with example usage: _get_num_gpus(ray_start_params, k8s_resource_limits, group_name) and returns: None, int, num_gpus