code: def make_flask_app(
      env: ServeEnv,
      forecaster_type: Optional[Type[Union[Estimator, Predictor]]],
      settings: Settings,
  ) -> Flask:
      if forecaster_type is not None:
          logger.info("Using dynamic predictor factory")
  
          ctor = forecaster_type.from_hyperparameters
  
          forecaster_fq_name = fqname_for(forecaster_type)
          forecaster_version = forecaster_type.__version__
  
          def predictor_factory(request) -> Predictor:
              return ctor(**request["configuration"])
  
      else:
          logger.info("Using static predictor factory")
  
          assert env is not None
          predictor = Predictor.deserialize(env.path.model)
  
          forecaster_fq_name = fqname_for(type(predictor))
          forecaster_version = predictor.__version__
  
          def predictor_factory(request) -> Predictor:
              return predictor
  
      logger.info(f"Using gluonts v{gluonts.__version__}")
      logger.info(
          f"Using forecaster {forecaster_fq_name} v{forecaster_version}"
      )
  
      execution_params = {
          "MaxConcurrentTransforms": settings.number_of_workers,
          "BatchStrategy": settings.sagemaker_batch_strategy,
          "MaxPayloadInMB": settings.sagemaker_max_payload_in_mb,
      }
  
      flask_app = make_app(
          predictor_factory,
          execution_params,
          batch_transform_config=env.batch_config,
          settings=settings,
      )
  
      return flask_app
  
file_path: gluonts/src/gluonts/shell/serve/__init__.py
imports: import logging
  import multiprocessing
  from ipaddress import IPv4Address
  from typing import List, Optional, Type, Union
  from flask import Flask
  import gluonts
  from gluonts.core import fqname_for
  from gluonts.model.estimator import Estimator
  from gluonts.model.predictor import Predictor
  from gluonts.shell.env import ServeEnv
  from gluonts.pydantic import BaseSettings
  from .app import make_app
label_desc: Use image node_id 1 for calling a global function with example usage: make_flask_app(env, forecaster_type, settings) and returns: flask_app, ctor, predictor