code: def get_translation():
      try:
          time_s = time.time()
          langpair = request.args["langpair"]
          src = request.args["text"]
          do_moses = request.args.get("do_moses", False)
          if langpair in MODELS_DICT:
              if do_moses:
                  result = MODELS_DICT[langpair].translate(
                      [src],
                      source_lang=langpair.split("-")[0],
                      target_lang=langpair.split("-")[1],
                  )
              else:
                  result = MODELS_DICT[langpair].translate([src])
  
              duration = time.time() - time_s
              logging.info(
                  f"Translated in {duration}. Input was: {request.args['text']} <############> Translation was: {result[0]}"
              )
              res = {"translation": result[0]}
              response = flask.jsonify(res)
              response.headers.add("Access-Control-Allow-Origin", "*")
              return response
  
          else:
              logging.error(
                  f"Got the following langpair: {langpair} which was not found"
              )
      except Exception as ex:
          res = {"translation": str(ex)}
          response = flask.jsonify(res)
          response.headers.add("Access-Control-Allow-Origin", "*")
          return res
  
file_path: NeMo/tools/nmt_webapp/nmt_service.py
imports: import json
  import time
  import flask
  import torch
  from flask import Flask, json, request
  from flask_cors import CORS
  import nemo.collections.nlp
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling a global function with example usage: get_translation() and returns: response, res