code: def _build_endpoint(
      request_model: RequestModel,
      dsk_composition: TaskComposition,
      response_model: ResponseModel,
  ) -> Callable[[RequestModel], ResponseModel]:
      def endpoint_fn(body: request_model):
          session = body.session if body.session else str(uuid.uuid4())
          _res = get(
              dsk_composition.dsk,
              dsk_composition.get_keys,
              cache=body.payload.dict(),
              sortkeys=dsk_composition.sortkeys,
          )
          return {
              "result": dict(
                  zip(dsk_composition.ep_dsk_output_keys, _res)
              ),
              "session": session,
          }
  
      endpoint_fn.__globals__["request_model"] = request_model
      endpoint_fn.__globals__["response_model"] = response_model
      return endpoint_fn
  
file_path: lightning-flash/src/flash/core/serve/interfaces/http.py
imports: import base64
  import uuid
  from io import BytesIO
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Callable, Dict, Optional
  from flash.core.serve.dag.task import get
  from flash.core.serve.dag.visualize import visualize
  from flash.core.serve.execution import ComponentJSON, MergedJSON, TaskComposition, build_composition, component_dag_content, merged_dag_content
  from flash.core.serve.interfaces.models import Alive, EndpointProtocol
  from flash.core.utilities.imports import _CYTOOLZ_AVAILABLE, _FASTAPI_AVAILABLE
label_desc: Use image node_id 1 for calling a global function with example usage: _build_endpoint(request_model, dsk_composition, response_model) and returns: endpoint_fn, dict