code: def filter_traceback(
      tb: types.TracebackType,
  ) -> types.TracebackType | None:
      out = None
      # Scan the traceback and collect relevant frames.
      frames = list(traceback.walk_tb(tb))
      for f, lineno in reversed(frames):
          if include_frame(f):
              out = types.TracebackType(out, f, f.f_lasti, lineno)
      return out
  
imports: from __future__ import annotations
  import functools
  import os
  import sys
  import traceback
  import types
  from typing import Any, Callable, TypeVar, cast
  from jax._src import config
  from jax._src import util
  from jax._src.lib import xla_extension
label_desc: Use image node_id 6 for calling a global function with example usage: filter_traceback(tb) and returns: out