code: def _tracer(self, meth):
      adapter = self
      ctx = self._orm_adapter_trace_context.get(
          {"stack": [], "last_depth": 0, "line_no": 0}
      )
      self._orm_adapter_trace_context.set(ctx)
  
      stack: List[Any] = ctx["stack"]  # type: ignore
      last_depth = len(stack)
      line_no: int = ctx["line_no"]  # type: ignore
      ctx["last_depth"] = last_depth
      stack.append((adapter, meth))
      indent = "    " * last_depth
  
      if hasattr(adapter, "mapper"):
          adapter_desc = (
              f"{adapter.__class__.__name__}"
              f"({adapter.role.name}, mapper={adapter.mapper})"
          )
      else:
          adapter_desc = (
              f"{adapter.__class__.__name__}({adapter.role.name})"
          )
  
      def tracer_fn(fn, arg):
          nonlocal line_no
  
          line_no += 1
  
          print(f"{indent} {line_no} {adapter_desc}", file=REAL_STDOUT)
          sub_indent = " " * len(f"{line_no} ")
  
          print(
              f"{indent}{sub_indent} -> "
              f"{meth} {_orm_adapter_trace_print(arg)}",
              file=REAL_STDOUT,
          )
          ctx["line_no"] = line_no
          ret = fn(arg)
  
          if DEBUG_ADAPT_STEP == line_no:
              breakpoint()
  
          if ret is arg:
              print(
                  f"{indent} {line_no} <- same object", file=REAL_STDOUT
              )
          else:
              print(
                  f"{indent} {line_no} <- {_orm_adapter_trace_print(ret)}",
                  file=REAL_STDOUT,
              )
  
          if last_depth == 0:
              print("", file=REAL_STDOUT)
          return ret
  
      try:
          yield tracer_fn
      finally:
          stack.pop(-1)
  
file_path: sqlalchemy/tools/trace_orm_adapter.py
imports: from __future__ import annotations
  import argparse
  import contextlib
  import contextvars
  import sys
  from typing import TYPE_CHECKING
  from sqlalchemy.orm import util
label_desc: Use image node_id 3 for calling the _ORMAdapterTrace obj's underlying member method code with example usage: obj._tracer(meth) and returns: ret