code: def _collect_spans(objref):
      class Collector:
          def __init__(self):
              self._spans = []
  
          def collect(self, objref):
              if hasattr(objref, "span"):
                  self._spans.append(objref.span)
  
          @property
          def get_spans(self):
              return self._spans
  
      pov = None
      if isinstance(objref, relay.Expr):
          pov = relay.analysis.post_order_visit
      elif isinstance(objref, (tir.Stmt, tir.expr.PrimExprWithOp)):
          pov = tir.stmt_functor.post_order_visit
      else:
          assert False, f"unsupported type {type(objref)}"
  
      c = Collector()
      pov(objref, c.collect)
      return c.get_spans
  
file_path: tvm/tests/python/relay/utils/tag_span.py
imports: import tvm
  from tvm import relay, tir
  from tvm.relay import expr
  from tvm.relay.expr_functor import ExprVisitor
label_desc: Use image node_id 3 for calling a global function with example usage: _collect_spans(objref) and returns: c, self