code: def format_exception(err, tb):
      # Try using Pytest to match the currently configured traceback style
      ExceptionInfo = _get_exceptioninfo()
      if (
          current_pytest_item.value is not None
          and ExceptionInfo is not None
      ):
          item = current_pytest_item.value
          return (
              str(
                  item.repr_failure(ExceptionInfo((type(err), err, tb)))
              )
              + "\n"
          )
  
      # Or use better_exceptions, if that's installed and enabled
      if "better_exceptions" in sys.modules:
          better_exceptions = sys.modules["better_exceptions"]
          if sys.excepthook is better_exceptions.excepthook:
              return "".join(
                  better_exceptions.format_exception(type(err), err, tb)
              )
  
      # If all else fails, use the standard-library formatting tools
      return "".join(traceback.format_exception(type(err), err, tb))
  
imports: import contextlib
  import os
  import sys
  import textwrap
  import traceback
  from inspect import getframeinfo
  from pathlib import Path
  from typing import Dict, NamedTuple, Optional, Type
  import hypothesis
  from hypothesis.errors import DeadlineExceeded, HypothesisException, StopTest, UnsatisfiedAssumption, _Trimmable
  from hypothesis.internal.compat import BaseExceptionGroup
  from hypothesis.utils.dynamicvariables import DynamicVariable
label_desc: Use image node_id 5 for calling a global function with example usage: format_exception(err, tb) and returns: str, unknown, str