code: def handle_java_exception(f):
      def deco(*args, **kwargs):
          import pyspark
  
          try:
              return f(*args, **kwargs)
          except py4j.protocol.Py4JJavaError as e:
              s = e.java_exception.toString()
  
              # py4j catches NoSuchElementExceptions to stop array iteration
              if s.startswith("java.util.NoSuchElementException"):
                  raise
  
              tpl = Env.jutils().handleForPython(e.java_exception)
              deepest, full, error_id = tpl._1(), tpl._2(), tpl._3()
              raise fatal_error_from_java_error_triplet(
                  deepest, full, error_id
              ) from None
          except pyspark.sql.utils.CapturedException as e:
              raise FatalError(
                  "%s\n\nJava stack trace:\n%s\n"
                  "Hail version: %s\n"
                  "Error summary: %s"
                  % (e.desc, e.stackTrace, hail.__version__, e.desc)
              ) from None
  
      return deco
  
imports: from typing import Mapping, Set, Tuple
  import abc
  import socket
  import socketserver
  import sys
  from threading import Thread
  import orjson
  import requests
  import py4j
  from py4j.java_gateway import JavaObject, JVMView
  import hail
  from hail.expr import construct_expr
  from hail.ir import JavaIR
  from hail.utils.java import FatalError, Env, scala_package_object
  from .backend import ActionTag, Backend, fatal_error_from_java_error_triplet
  from ..hail_logging import Logger
  import http.client
label_desc: Use image node_id 3 for calling a global function with example usage: handle_java_exception(f) and returns: deco, f