code: def extract_stateless_function(
      user_defined_function_proto,
      runtime_context: RuntimeContext,
      operator_state_store,
  ):
      """
      Extracts user-defined-function from the proto representation of a
      :class:`Function`.
  
      :param user_defined_function_proto: the proto representation of the Python :class:`Function`
      :param runtime_context: the streaming runtime context
      :param operator_state_store: operator state store for getting broadcast states
      """
      from pyflink.fn_execution import flink_fn_execution_pb2
  
      func_type = user_defined_function_proto.function_type
      has_side_output = user_defined_function_proto.has_side_output
      UserDefinedDataStreamFunction = (
          flink_fn_execution_pb2.UserDefinedDataStreamFunction
      )
  
      if func_type == UserDefinedDataStreamFunction.REVISE_OUTPUT:
  
          def open_func():
              pass
  
          def close_func():
              pass
  
          def revise_output(value):
              # VALUE[CURRENT_TIMESTAMP, CURRENT_WATERMARK, NORMAL_DATA]
              timestamp = value[0]
              element = value[2]
              yield Row(timestamp, element)
  
          process_element_func = revise_output
  
      else:
          user_defined_func = pickle.loads(
              user_defined_function_proto.payload
          )
  
          def open_func():
              if hasattr(user_defined_func, "open"):
                  user_defined_func.open(runtime_context)
  
          def close_func():
              if hasattr(user_defined_func, "close"):
                  user_defined_func.close()
  
          if func_type == UserDefinedDataStreamFunction.PROCESS:
              process_element = user_defined_func.process_element
              ctx = InternalProcessFunctionContext(
                  NonKeyedTimerServiceImpl()
              )
  
              def wrapped_func(value):
                  # VALUE[CURRENT_TIMESTAMP, CURRENT_WATERMARK, NORMAL_DATA]
                  timestamp = value[0]
                  watermark = value[1]
                  ctx.set_timestamp(timestamp)
                  ctx.timer_service().advance_watermark(watermark)
                  results = process_element(value[2], ctx)
                  yield from _emit_results(
                      timestamp, watermark, results, has_side_output
                  )
  
              process_element_func = wrapped_func
  
          elif func_type == UserDefinedDataStreamFunction.CO_PROCESS:
              process_element1 = user_defined_func.process_element1
              process_element2 = user_defined_func.process_element2
              ctx = InternalProcessFunctionContext(
                  NonKeyedTimerServiceImpl()
              )
  
              def wrapped_func(value):
                  # VALUE[CURRENT_TIMESTAMP, CURRENT_WATERMARK, [isLeft, leftInput, rightInput]]
                  timestamp = value[0]
                  watermark = value[1]
                  ctx.set_timestamp(timestamp)
                  ctx.timer_service().advance_watermark(watermark)
  
                  normal_data = value[2]
                  if normal_data[0]:
                      results = process_element1(normal_data[1], ctx)
                  else:
                      results = process_element2(normal_data[2], ctx)
  
                  yield from _emit_results(
                      timestamp, watermark, results, has_side_output
                  )
  
              process_element_func = wrapped_func
  
          elif (
              func_type
              == UserDefinedDataStreamFunction.CO_BROADCAST_PROCESS
          ):
              user_defined_func = cast(
                  BroadcastProcessFunction, user_defined_func
              )
              process_element = user_defined_func.process_element
              process_broadcast_element = (
                  user_defined_func.process_broadcast_element
              )
              broadcast_ctx = InternalBroadcastProcessFunctionContext(
                  NonKeyedTimerServiceImpl(), operator_state_store
              )
              read_only_broadcast_ctx = (
                  InternalBroadcastProcessFunctionReadOnlyContext(
                      NonKeyedTimerServiceImpl(), operator_state_store
                  )
              )
  
              def wrapped_func(value):
                  # VALUE[CURRENT_TIMESTAMP, CURRENT_WATERMARK,
                  #   [isNormal, normalInput, broadcastInput]]
                  timestamp = value[0]
                  watermark = value[1]
                  broadcast_ctx.set_timestamp(timestamp)
                  cast(
                      TimerServiceImpl, broadcast_ctx.timer_service()
                  ).advance_watermark(watermark)
                  read_only_broadcast_ctx.set_timestamp(timestamp)
                  cast(
                      TimerServiceImpl,
                      read_only_broadcast_ctx.timer_service(),
                  ).advance_watermark(watermark)
  
                  data = value[2]
                  if data[0]:
                      results = process_element(
                          data[1], read_only_broadcast_ctx
                      )
                  else:
                      results = process_broadcast_element(
                          data[2], broadcast_ctx
                      )
                  yield from _emit_results(
                      timestamp, watermark, results, has_side_output
                  )
  
              process_element_func = wrapped_func
  
          else:
              raise Exception(
                  "Unsupported function_type: " + str(func_type)
              )
  
      return open_func, close_func, process_element_func
  
imports: import abc
  from typing import cast
  from pyflink.common import Row
  from pyflink.common.serializer import VoidNamespaceSerializer
  from pyflink.datastream import TimeDomain, RuntimeContext
  from pyflink.datastream.functions import BroadcastProcessFunction
  from pyflink.datastream.window import WindowOperationDescriptor
  from pyflink.fn_execution import pickle
  from pyflink.fn_execution.datastream.process.input_handler import RunnerInputHandler, TimerHandler, _emit_results
  from pyflink.fn_execution.datastream import operations
  from pyflink.fn_execution.datastream.process.runtime_context import StreamingRuntimeContext
  from pyflink.fn_execution.datastream.process.process_function import InternalKeyedProcessFunctionOnTimerContext, InternalKeyedProcessFunctionContext, InternalProcessFunctionContext, InternalBroadcastProcessFunctionContext, InternalBroadcastProcessFunctionReadOnlyContext, InternalKeyedBroadcastProcessFunctionContext, InternalKeyedBroadcastProcessFunctionReadOnlyContext, InternalKeyedBroadcastProcessFunctionOnTimerContext
  from pyflink.fn_execution.datastream.process.timerservice_impl import TimerServiceImpl, InternalTimerServiceImpl, NonKeyedTimerServiceImpl
  from pyflink.fn_execution.datastream.window.window_operator import WindowOperator
  from pyflink.fn_execution.metrics.process.metric_impl import GenericMetricGroup
label_desc: Use image node_id 1 for calling a global function with example usage: extract_stateless_function(user_defined_function_proto, runtime_context, operator_state_store) and returns: open_func,  close_func,  process_element_func