code: def test_cluster_resources():
      """Test ray.data._internal.util.cluster_resources()."""
      resources = {"CPU": 4, "GPU": 1}
      cache_interval_s = 0.1
      with patch.object(
          ray.data._internal.util,
          "CLUSTER_RESOURCES_FETCH_INTERVAL_SECONDS",
          cache_interval_s,
      ):
          with patch(
              "ray.cluster_resources",
              return_value=resources,
          ) as ray_cluster_resources:
              # The first call should call ray.cluster_resources().
              assert (
                  ray.data._internal.util.cluster_resources()
                  == resources
              )
              assert ray_cluster_resources.call_count == 1
              # The second call should return the cached value.
              assert (
                  ray.data._internal.util.cluster_resources()
                  == resources
              )
              assert ray_cluster_resources.call_count == 1
              time.sleep(cache_interval_s)
              # After the cache interval, the third call should call
              # ray.cluster_resources() again.
              assert (
                  ray.data._internal.util.cluster_resources()
                  == resources
              )
              assert ray_cluster_resources.call_count == 2
  
file_path: ray/python/ray/data/tests/test_util.py
imports: import time
  from typing import Any, Dict, Optional
  from unittest.mock import patch
  import numpy
  import pytest
  import ray
  from ray.data._internal.logical.operators.read_operator import Read
  from ray.data._internal.memory_tracing import leak_report, trace_allocation, trace_deallocation
  from ray.data._internal.util import _check_pyarrow_version, _split_list
  from ray.data.datasource.parquet_datasource import ParquetDatasource
  from ray.data.tests.conftest import *
label_desc: Use image node_id 7 for calling a global function with example usage: test_cluster_resources() without return types