code: def _get_avail_mem_per_ray_worker_node(
      num_cpus_per_node,
      num_gpus_per_node,
      object_store_memory_per_node,
  ):
      num_cpus = _get_cpu_cores()
  
      if num_cpus_per_node > num_cpus:
          raise ValueError(
              "cpu number per Ray worker node should be <= spark worker node CPU cores, "
              f"you set cpu number per Ray worker node to {num_cpus_per_node} but "
              f"spark worker node CPU core number is {num_cpus}."
          )
      num_task_slots = num_cpus // num_cpus_per_node
  
      if num_gpus_per_node > 0:
          num_gpus = _get_num_physical_gpus()
          if num_gpus_per_node > num_gpus:
              raise ValueError(
                  "gpu number per Ray worker node should be <= spark worker node "
                  "GPU number, you set cpu number per Ray worker node to "
                  f"{num_cpus_per_node} but spark worker node CPU core number "
                  f"is {num_cpus}."
              )
          if num_task_slots > num_gpus // num_gpus_per_node:
              num_task_slots = num_gpus // num_gpus_per_node
  
      physical_mem_bytes = _get_spark_worker_total_physical_memory()
      shared_mem_bytes = _get_spark_worker_total_shared_memory()
  
      (
          ray_worker_node_heap_mem_bytes,
          ray_worker_node_object_store_bytes,
          warning_msg,
      ) = _calc_mem_per_ray_worker_node(
          num_task_slots,
          physical_mem_bytes,
          shared_mem_bytes,
          object_store_memory_per_node,
      )
      return (
          ray_worker_node_heap_mem_bytes,
          ray_worker_node_object_store_bytes,
          None,
          warning_msg,
      )
  
imports: import subprocess
  import os
  import sys
  import random
  import threading
  import collections
  import logging
  import time
label_desc: Use image node_id 17 for calling a global function with example usage: _get_avail_mem_per_ray_worker_node(num_cpus_per_node, num_gpus_per_node, object_store_memory_per_node) and returns: ray_worker_node_heap_mem_bytes,  ray_worker_node_object_store_bytes,  None,  warning_msg