code: def main(_):
      # Create the models we support:
      with open(FLAGS.configuration) as configuration_file:
          configuration = json.load(configuration_file)
  
      # Read in the set of query processors.
      processors = {}
      for processor_configuration in configuration["configuration"]:
          key = (
              processor_configuration["source_language"],
              processor_configuration["target_language"],
              processor_configuration["label"],
          )
  
          processors[key] = transformer_model.TransformerModel(
              processor_configuration
          )
  
      # Read in the list of supported languages.
      languages = {}
      for language in configuration["language"]:
          languages[language["code"]] = {
              "code": language["code"],
              "name": language["name"],
          }
  
      # Create flask to serve all paths starting with '/polymer' from the static
      # path.  This is to served non-vulcanized components.
      app = Flask(
          __name__.split(".")[0],
          static_url_path="/polymer",
          static_folder=FLAGS.static_path,
      )
      app.json_encoder = NumpySerializationFix
  
      # Disable static file caching.
      app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 0
  
      @app.route("/api/language_list/")
      def language_list():  # pylint: disable=unused-variable
          """Responds to /api/language_list with the supported languages.
  
          Returns:
            JSON for the languages.
          """
          return jsonify({"language": list(languages.values())})
  
      @app.route("/api/list_models/")
      def list_models():  # pylint: disable=unused-variable
          """Responds to /api/list_models with the supported modes.
  
  
          Returns:
            JSON for the supported models.
          """
          # pylint: disable=g-complex-comprehension
          configuration_list = [
              {
                  "id": label,
                  "source_language": languages[source_code],
                  "target_language": languages[target_code],
              }
              for source_code, target_code, label in processors
          ]
          return jsonify({"configuration": configuration_list})
  
      @app.route("/debug", methods=["GET"])
      def query():  # pylint: disable=unused-variable
          """Responds to /debug with processing results.
  
          Returns:
            JSON for the query's result.
          """
          query = request.args.get("source")
          source_language = request.args.get("sl")
          target_language = request.args.get("tl")
          model_name = request.args.get("id")
          processor = processors[
              (source_language, target_language, model_name)
          ]
          return jsonify(processor.process(query))
  
      # Catchall for all other paths.  Any other path should get the basic index
      # page, the polymer side will determine what view to show and what REST calls
      # to make for data.
      @app.route("/", defaults={"path": ""})
      @app.route("/<path:path>")
      def root(path):  # pylint: disable=unused-variable
          """Responds to all other non-static paths with index.html.
  
          Args:
            path: Unused path.
  
          Returns:
            The landing page html text.
          """
          if (
              path == "index.js"
              or path == "webcomponentsjs/webcomponents-lite.js"
          ):
              # Some vulcanizing methods bundle the javascript into a index.js file
              # paired with index.html but leave two important webcomponents js files
              # outside of the bundle.  If requesting those special files, fetch them
              # directly rather than from a /static sub-directory.
              return send_from_directory(FLAGS.static_path, path)
          # Everything else should redirect to the main landing page.  Since we
          # use a single page app, any initial url requests may include random
          # paths (that don't start with /api or /static) which all should be
          # served by the main landing page.
          return send_from_directory(FLAGS.static_path, "index.html")
  
      # Run the server.
      tf.logging.info("############# READY ##################")
      options = {
          "bind": ":8010",
          "timeout": 600,
          "workers": 4,
          "reload": True,
          "spew": True,
          "worker_class": "gevent",
      }
      DebugFrontendApplication(app, options).run()
  
file_path: tensor2tensor/tensor2tensor/insights/server.py
imports: import json
  from flask import Flask
  from flask import jsonify
  from flask import request
  from flask import send_from_directory
  from flask.json import JSONEncoder
  from gunicorn.app.base import BaseApplication
  from gunicorn.six import iteritems
  import numpy
  from tensor2tensor.insights import transformer_model
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: main(_) and returns: jsonify, jsonify, jsonify, send_from_directory, send_from_directory