code: def test_shared_memory_and_inline_worker_heap(shutdown_only):
      """Test objects allocated in shared memory"""
      import numpy as np
  
      info = ray.init(
          object_store_memory=100 * MiB,
          _system_config={
              **_SYSTEM_CONFIG,
              **{
                  "max_direct_call_object_size": 10 * MiB,
                  "task_rpc_inlined_bytes_limit": 100 * MiB,
              },
          },
      )
  
      # Allocate 80MiB data
      objs_in_use = ray.get(
          [
              ray.put(np.zeros(20 * MiB, dtype=np.uint8))
              for _ in range(4)
          ]
      )
  
      expected = {
          "MMAP_SHM": 80 * MiB,
          "MMAP_DISK": 0,
          "SPILLED": 0,
          "WORKER_HEAP": 0,
      }
  
      wait_for_condition(
          # 1KiB for metadata difference
          lambda: approx_eq_dict_in(
              objects_by_loc(info), expected, 2 * KiB
          ),
          timeout=20,
          retry_interval_ms=500,
      )
  
      # Allocate inlined task returns
      @ray.remote(num_cpus=0.1)
      def func():
          return np.zeros(4 * MiB, dtype=np.uint8)
  
      tasks_with_inlined_return = [func.remote() for _ in range(5)]
  
      expected = {
          "MMAP_SHM": 80 * MiB,
          "MMAP_DISK": 0,
          "SPILLED": 0,
          "WORKER_HEAP": 20 * MiB,
      }
  
      returns = ray.get(tasks_with_inlined_return)
  
      wait_for_condition(
          # 4 KiB for metadata difference
          lambda: approx_eq_dict_in(
              objects_by_loc(info), expected, 4 * KiB
          ),
          timeout=20,
          retry_interval_ms=500,
      )
  
      # Free all of them
      del objs_in_use
      del returns
      del tasks_with_inlined_return
  
      expected = {
          "MMAP_SHM": 0,
          "MMAP_DISK": 0,
          "SPILLED": 0,
          "WORKER_HEAP": 0,
      }
  
      wait_for_condition(
          # 1KiB for metadata difference
          lambda: approx_eq_dict_in(
              objects_by_loc(info), expected, 2 * KiB
          ),
          timeout=20,
          retry_interval_ms=500,
      )
  
file_path: ray/python/ray/tests/test_object_store_metrics.py
imports: from collections import defaultdict
  import pytest
  from typing import Dict
  import numpy
  import sys
  import requests
  import ray
  from ray._private.test_utils import raw_metrics, wait_for_condition
  from ray._private.worker import RayContext
label_desc: Use image node_id 5 for calling a global function with example usage: test_shared_memory_and_inline_worker_heap(shutdown_only) and returns: np