code: def get_gateway():
      # type: () -> JavaGateway
      global _gateway
      global _lock
      with _lock:
          if _gateway is None:
              # Set the level to WARN to mute the noisy INFO level logs
              logger.level = WARN
              # if Java Gateway is already running
              if "PYFLINK_GATEWAY_PORT" in os.environ:
                  gateway_port = int(os.environ["PYFLINK_GATEWAY_PORT"])
                  gateway_param = GatewayParameters(
                      port=gateway_port, auto_convert=True
                  )
                  _gateway = JavaGateway(
                      gateway_parameters=gateway_param,
                      callback_server_parameters=CallbackServerParameters(
                          port=0,
                          daemonize=True,
                          daemonize_connections=True,
                      ),
                  )
              else:
                  _gateway = launch_gateway()
  
              callback_server = _gateway.get_callback_server()
              callback_server_listening_address = (
                  callback_server.get_listening_address()
              )
              callback_server_listening_port = (
                  callback_server.get_listening_port()
              )
              _gateway.jvm.org.apache.flink.client.python.PythonEnvUtils.resetCallbackClient(
                  _gateway.java_gateway_server,
                  callback_server_listening_address,
                  callback_server_listening_port,
              )
              # import the flink view
              import_flink_view(_gateway)
              install_exception_handler()
              install_py4j_hooks()
              _gateway.entry_point.put(
                  "PythonFunctionFactory", PythonFunctionFactory()
              )
              _gateway.entry_point.put("Watchdog", Watchdog())
      return _gateway
  
imports: import importlib
  import os
  import shlex
  import shutil
  import struct
  import tempfile
  import time
  from logging import WARN
  from threading import RLock
  from py4j.java_gateway import java_import, logger, JavaGateway, GatewayParameters, CallbackServerParameters
  from pyflink.find_flink_home import _find_flink_home
  from pyflink.pyflink_gateway_server import launch_gateway_server_process
  from pyflink.util.exceptions import install_exception_handler, install_py4j_hooks
label_desc: Use image node_id 2 for calling a global function with example usage: get_gateway() and returns: _gateway