code: def ignore_warnings(warningcls):
      """
      Context manager to suppress warnings during tests.
  
      .. note::
  
         Do not use this with SymPyDeprecationWarning in the tests.
         warns_deprecated_sympy() should be used instead.
  
      This function is useful for suppressing warnings during tests. The warns
      function should be used to assert that a warning is raised. The
      ignore_warnings function is useful in situation when the warning is not
      guaranteed to be raised (e.g. on importing a module) or if the warning
      comes from third-party code.
  
      This function is also useful to prevent the same or similar warnings from
      being issue twice due to recursive calls.
  
      When the warning is coming (reliably) from SymPy the warns function should
      be preferred to ignore_warnings.
  
      >>> from sympy.utilities.exceptions import ignore_warnings
      >>> import warnings
  
      Here's a warning:
  
      >>> with warnings.catch_warnings():  # reset warnings in doctest
      ...     warnings.simplefilter('error')
      ...     warnings.warn('deprecated', UserWarning)
      Traceback (most recent call last):
        ...
      UserWarning: deprecated
  
      Let's suppress it with ignore_warnings:
  
      >>> with warnings.catch_warnings():  # reset warnings in doctest
      ...     warnings.simplefilter('error')
      ...     with ignore_warnings(UserWarning):
      ...         warnings.warn('deprecated', UserWarning)
  
      (No warning emitted)
  
      See Also
      ========
      sympy.utilities.exceptions.SymPyDeprecationWarning
      sympy.utilities.exceptions.sympy_deprecation_warning
      sympy.utilities.decorator.deprecated
      sympy.testing.pytest.warns_deprecated_sympy
  
      """
      # Absorbs all warnings in warnrec
      with warnings.catch_warnings(record=True) as warnrec:
          # Make sure our warning doesn't get filtered
          warnings.simplefilter("always", warningcls)
          # Now run the test
          yield
  
      # Reissue any warnings that we aren't testing for
      for w in warnrec:
          if not issubclass(w.category, warningcls):
              warnings.warn_explicit(
                  w.message, w.category, w.filename, w.lineno
              )
  
file_path: sympy/sympy/utilities/exceptions.py
imports: import warnings
  import contextlib
  from textwrap import dedent
label_desc: Use image node_id 2 for calling a global function with example usage: ignore_warnings(warningcls) without return types