code: def check_filtered_stack_trace(
      test, etype, f, frame_patterns=(), filter_mode="remove_frames"
  ):
      with config.traceback_filtering(filter_mode):
          test.assertRaises(etype, f)
          e = get_exception(etype, f)
      c = e.__cause__
      if filter_mode == "quiet_remove_frames":
          if sys.version_info >= (3, 11):
              assert any("For simplicity" in x for x in e.__notes__)
          else:
              test.assertIsInstance(c, jax.errors.SimplifiedTraceback)
      elif filter_mode == "remove_frames":
          test.assertIsInstance(c, traceback_util.UnfilteredStackTrace)
      else:
          test.assertFalse(
              isinstance(c, traceback_util.UnfilteredStackTrace)
          )
  
      if frame_patterns:
          frames = []
          for frame, lineno in traceback.walk_tb(e.__traceback__):
              if filter_mode == "tracebackhide":
                  if "__tracebackhide__" in frame.f_locals.keys():
                      continue
              frames.append((frame, lineno))
  
          c_tb = traceback.format_list(
              traceback.StackSummary.extract(frames)
          )
          for (fname_pat, line_pat), frame_fmt in zip(
              reversed(frame_patterns), reversed(c_tb)
          ):
              file = re.escape(__file__)
              fname_pat = re.escape(fname_pat)
              line_pat = re.escape(line_pat)
              full_pat = (
                  f'  File "{file}", line '
                  r"[0-9]+"
                  f", in {fname_pat}"
                  r"\n\s*"
                  f"{line_pat}"
              )
              test.assertRegex(frame_fmt, full_pat)
  
imports: import re
  import sys
  import traceback
  from absl.testing import absltest
  from absl.testing import parameterized
  import jax
  import jax.numpy
  from jax import grad, jit, vmap, lax
  from jax._src import config
  from jax._src import core
  from jax._src import source_info_util
  from jax._src import test_util
  from jax._src import traceback_util
label_desc: Use image node_id 2 for calling a global function with example usage: check_filtered_stack_trace(test, etype, f, frame_patterns, filter_mode) without return types