code: def test_memory_tracing(enabled):
      ctx = ray.data.context.DataContext.get_current()
      ctx.trace_allocations = enabled
      ref1 = ray.put(np.zeros(1024 * 1024))
      ref2 = ray.put(np.zeros(1024 * 1024))
      ref3 = ray.put(np.zeros(1024 * 1024))
      trace_allocation(ref1, "test1")
      trace_allocation(ref2, "test2")
      trace_allocation(ref3, "test5")
      trace_deallocation(ref1, "test3", free=False)
      trace_deallocation(ref2, "test4", free=True)
      ray.get(ref1)
      with pytest.raises(ray.exceptions.ObjectFreedError):
          ray.get(ref2)
      report = leak_report()
      print(report)
  
      if enabled:
          assert "Leaked object, created at test1" in report, report
          assert "Leaked object, created at test5" in report, report
          assert "Freed object from test2 at test4" in report, report
          assert "skipped dealloc at test3" in report, report
      else:
          assert "test1" not in report, report
          assert "test2" not in report, report
          assert "test3" not in report, report
          assert "test4" not in report, report
          assert "test5" not in report, report
  
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 4 for calling a global function with example usage: test_memory_tracing(enabled) without return types