code: def _global_except_hook(exctype, value, traceback):
      """Catches an unhandled exception and call MPI_Abort()."""
      try:
          if _orig_except_hook:
              _orig_except_hook(exctype, value, traceback)
          else:
              sys.__excepthook__(exctype, value, traceback)
  
      finally:
          import mpi4py.MPI
  
          rank = mpi4py.MPI.COMM_WORLD.Get_rank()
          sys.stderr.write("\n")
          sys.stderr.write(
              "******************************************\n"
          )
          sys.stderr.write("ChainerMN:\n")
          sys.stderr.write(
              "   Uncaught exception on rank {}.\n".format(rank)
          )
          sys.stderr.write(
              "   Calling MPI_Abort() to shut down MPI...\n"
          )
          sys.stderr.write(
              "******************************************\n"
          )
          sys.stderr.write("\n\n")
          sys.stderr.flush()
  
          try:
              import mpi4py.MPI
  
              mpi4py.MPI.COMM_WORLD.Abort(1)
          except Exception as e:
              # Something is completely broken...
              # There's nothing we can do any more
              sys.stderr.write(
                  "Sorry, failed to stop MPI and the process may hang.\n"
              )
              sys.stderr.flush()
              raise e
  
imports: import os
  import sys
  import warnings
label_desc: Use image node_id 1 for calling a global function with example usage: _global_except_hook(exctype, value, traceback) without return types