code: def locate_app(module_name, app_name, raise_if_not_found=True):
      try:
          __import__(module_name)
      except ImportError:
          # Reraise the ImportError if it occurred within the imported module.
          # Determine this by checking whether the trace has a depth > 1.
          if sys.exc_info()[2].tb_next:
              raise NoAppException(
                  f"While importing {module_name!r}, an ImportError was"
                  f" raised:\n\n{traceback.format_exc()}"
              ) from None
          elif raise_if_not_found:
              raise NoAppException(
                  f"Could not import {module_name!r}."
              ) from None
          else:
              return
  
      module = sys.modules[module_name]
  
      if app_name is None:
          return find_best_app(module)
      else:
          return find_app_by_string(module, app_name)
  
imports: from __future__ import annotations
  import ast
  import importlib.metadata
  import inspect
  import os
  import platform
  import re
  import sys
  import traceback
  import typing
  from functools import update_wrapper
  from operator import itemgetter
  import click
  from click.core import ParameterSource
  from werkzeug import run_simple
  from werkzeug.serving import is_running_from_reloader
  from werkzeug.utils import import_string
  from .globals import current_app
  from .helpers import get_debug_flag
  from .helpers import get_load_dotenv
label_desc: Use image node_id 5 for calling a global function with example usage: locate_app(module_name, app_name, raise_if_not_found) and returns: find_best_app, find_app_by_string