code: def test_internal_free_non_owned(shutdown_only):
      info = ray.init(num_cpus=1)
  
      @ray.remote
      def gen_data():
          return ray.put(np.zeros(1024 * 1024))
  
      @ray.remote
      def do_free(ref_list):
          ray._private.internal_api.free(ref_list, local_only=False)
          for ref in ref_list:
              with pytest.raises(ObjectFreedError):
                  ray.get(ref)
  
      # Can free locally owned objects from remote worker.
      ref_1 = ray.put(np.zeros(1024 * 1024))
      ref_2 = ray.put(np.zeros(1024 * 1024))
      ray.get(do_free.remote([ref_1, ref_2]))
  
      # Can free remotely owned objects from local worker.
      ref_3 = ray.get(gen_data.remote())
      ref_4 = ray.get(gen_data.remote())
      ray._private.internal_api.free([ref_3, ref_4], local_only=False)
      for ref in [ref_3, ref_4]:
          with pytest.raises(ObjectFreedError):
              ray.get(ref)
  
      # Memory was really freed.
      info = memory_summary(info.address_info["address"])
      assert "Plasma memory usage 0 MiB, 0 objects" in info, info
  
imports: import json
  import logging
  import os
  import sys
  import time
  import numpy
  import pytest
  import ray._private.profiling
  import ray.cluster_utils
  from ray._private.internal_api import memory_summary
  from ray._private.test_utils import client_test_enabled, wait_for_condition
  from ray.exceptions import ObjectFreedError
label_desc: Use image node_id 2 for calling a global function with example usage: test_internal_free_non_owned(shutdown_only) and returns: ray