code: def server(model, allowed_origins=None):
      middleware = (
          [Middleware(CORSMiddleware, allow_origins=allowed_origins)]
          if allowed_origins
          else None
      )
      app = FastAPI(middleware=middleware)
  
      config = model.config
      input_features = {f[COLUMN] for f in config["input_features"]}
  
      @app.get("/")
      def check_health():
          return NumpyJSONResponse({"message": "Ludwig server is up"})
  
      @app.post("/predict")
      async def predict(request: Request):
          try:
              form = await request.form()
              entry, files = convert_input(
                  form, model.model.input_features
              )
          except Exception:
              logger.exception("Failed to parse predict form")
              return NumpyJSONResponse(
                  COULD_NOT_RUN_INFERENCE_ERROR, status_code=500
              )
  
          try:
              if (entry.keys() & input_features) != input_features:
                  missing_features = set(input_features) - set(
                      entry.keys()
                  )
                  return NumpyJSONResponse(
                      {
                          "error": "Data received does not contain all input features. "
                          f"Missing features: {missing_features}."
                      },
                      status_code=400,
                  )
              try:
                  resp, _ = model.predict(
                      dataset=[entry], data_format=dict
                  )
                  resp = resp.to_dict("records")[0]
                  return NumpyJSONResponse(resp)
              except Exception as exc:
                  logger.exception(f"Failed to run predict: {exc}")
                  return NumpyJSONResponse(
                      COULD_NOT_RUN_INFERENCE_ERROR, status_code=500
                  )
          finally:
              for f in files:
                  os.remove(f.name)
  
      @app.post("/batch_predict")
      async def batch_predict(request: Request):
          try:
              form = await request.form()
              data, files = convert_batch_input(
                  form, model.model.input_features
              )
              data_df = pd.DataFrame.from_records(
                  data["data"],
                  index=data.get("index"),
                  columns=data["columns"],
              )
          except Exception:
              logger.exception("Failed to parse batch_predict form")
              return NumpyJSONResponse(
                  COULD_NOT_RUN_INFERENCE_ERROR, status_code=500
              )
  
          if (set(data_df.columns) & input_features) != input_features:
              missing_features = set(input_features) - set(
                  data_df.columns
              )
              return NumpyJSONResponse(
                  {
                      "error": "Data received does not contain all input features. "
                      f"Missing features: {missing_features}."
                  },
                  status_code=400,
              )
          try:
              resp, _ = model.predict(dataset=data_df)
              resp = resp.to_dict("split")
              return NumpyJSONResponse(resp)
          except Exception:
              logger.exception("Failed to run batch_predict: {}")
              return NumpyJSONResponse(
                  COULD_NOT_RUN_INFERENCE_ERROR, status_code=500
              )
  
      return app
  
imports: import argparse
  import io
  import json
  import logging
  import os
  import sys
  import tempfile
  import pandas
  import torch
  from torchvision.io import decode_image
  from ludwig.api import LudwigModel
  from ludwig.constants import AUDIO, COLUMN
  from ludwig.contrib import add_contrib_callback_args
  from ludwig.globals import LUDWIG_VERSION
  from ludwig.utils.print_utils import get_logging_level_registry, print_ludwig
  from ludwig.utils.server_utils import NumpyJSONResponse
label_desc: Use image node_id 1 for calling a global function with example usage: server(model, allowed_origins) and returns: app, NumpyJSONResponse, NumpyJSONResponse, NumpyJSONResponse, NumpyJSONResponse, NumpyJSONResponse, NumpyJSONResponse, NumpyJSONResponse, NumpyJSONResponse, NumpyJSONResponse