code: def test_many_fractional_resources(shutdown_only):
      ray.init(num_cpus=2, num_gpus=2, resources={"Custom": 2})
  
      @ray.remote
      def g():
          return 1
  
      @ray.remote
      def f(block, accepted_resources):
          true_resources = {
              resource: value[0][1]
              for resource, value in ray._private.worker.get_resource_ids().items()
          }
          if block:
              ray.get(g.remote())
          return dicts_equal(true_resources, accepted_resources)
  
      # Check that the resource are assigned correctly.
      result_ids = []
      for i in range(100):
          rand1 = random.random()
          rand2 = random.random()
          rand3 = random.random()
  
          resource_set = {"CPU": int(rand1 * 10000) / 10000}
          result_ids.append(
              f._remote(
                  [False, resource_set], num_cpus=resource_set["CPU"]
              )
          )
  
          resource_set = {"CPU": 1, "GPU": int(rand1 * 10000) / 10000}
          result_ids.append(
              f._remote(
                  [False, resource_set], num_gpus=resource_set["GPU"]
              )
          )
  
          resource_set = {
              "CPU": 1,
              "Custom": int(rand1 * 10000) / 10000,
          }
          result_ids.append(
              f._remote(
                  [False, resource_set],
                  resources={"Custom": resource_set["Custom"]},
              )
          )
  
          resource_set = {
              "CPU": int(rand1 * 10000) / 10000,
              "GPU": int(rand2 * 10000) / 10000,
              "Custom": int(rand3 * 10000) / 10000,
          }
          result_ids.append(
              f._remote(
                  [False, resource_set],
                  num_cpus=resource_set["CPU"],
                  num_gpus=resource_set["GPU"],
                  resources={"Custom": resource_set["Custom"]},
              )
          )
          result_ids.append(
              f._remote(
                  [True, resource_set],
                  num_cpus=resource_set["CPU"],
                  num_gpus=resource_set["GPU"],
                  resources={"Custom": resource_set["Custom"]},
              )
          )
      assert all(ray.get(result_ids))
  
      # Check that the available resources at the end are the same as the
      # beginning.
      stop_time = time.time() + 10
      correct_available_resources = False
      while time.time() < stop_time:
          available_resources = ray.available_resources()
          if (
              "CPU" in available_resources
              and ray.available_resources()["CPU"] == 2.0
              and "GPU" in available_resources
              and ray.available_resources()["GPU"] == 2.0
              and "Custom" in available_resources
              and ray.available_resources()["Custom"] == 2.0
          ):
              correct_available_resources = True
              break
      if not correct_available_resources:
          assert False, "Did not get correct available resources."
  
file_path: ray/python/ray/tests/test_basic_3.py
imports: import logging
  import random
  import sys
  import time
  import pytest
  import ray
  import ray.cluster_utils
  from ray._private.test_utils import dicts_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_many_fractional_resources(shutdown_only) and returns: int, dicts_equal