code: def snapshot(gc_generation=0) -> MallocInstant:
      """
      Take a snapshot of the current "malloc instant", similar to an allocation version of time.perf_counter() (etc.).
      """
      if gc_generation is not None:
          # By collecting, we ensure we're only recording long term objects; this works best when GC
          # is disabled, see the comment in `allocation_benchmark` below.
          gc.collect(gc_generation)
      return MallocInstant(tracemalloc.take_snapshot())
  
file_path: stellargraph/tests/test_utils/alloc.py
imports: import gc
  import pytest
  import tracemalloc
label_desc: Use image node_id 1 for calling a global function with example usage: snapshot(gc_generation) and returns: MallocInstant