code: def trace_allocation(ref: ray.ObjectRef, loc: str) -> None:
      """Record that an object has been created.
  
      Args:
          ref: The object created.
          loc: A human-readable string identifying the call site.
      """
      ctx = DataContext.get_current()
      if ctx.trace_allocations:
          tracer = _get_mem_actor()
          # TODO: it would be nice to determine loc automatically based on the stack.
          ray.get(tracer.trace_alloc.remote([ref], loc))
  
file_path: ray/python/ray/data/_internal/memory_tracing.py
imports: from io import StringIO
  from typing import Dict, List
  import ray
  from ray.data.context import DataContext
label_desc: Use image node_id 1 for calling a global function with example usage: trace_allocation(ref, loc) without return types