code: def _format_exception(exc):
      if exc is None:
          return None
      # TODO(kataoka): Use traceback.format_exception(exc) in Python 3.10
      return "".join(
          traceback.TracebackException.from_exception(exc).format()
      )
  
imports: import functools
  import inspect
  import os
  import random
  from typing import Tuple, Type
  import traceback
  import unittest
  import warnings
  import numpy
  import cupy
  from cupy.testing import _array
  from cupy.testing import _parameterized
  import cupyx
  import cupyx.scipy.sparse
  from cupy.testing._pytest_impl import is_available
label_desc: Use image node_id 1 for calling a global function with example usage: _format_exception(exc) and returns: str, None