code: def app_instance(app_dir=None, studies=None, conf=None):
      app_dir = app_dir if app_dir else settings.MONAI_LABEL_APP_DIR
      studies = studies if studies else settings.MONAI_LABEL_STUDIES
      cache_key = f"{app_dir}{studies}"
  
      global apps
      app = apps.get(cache_key)
      if app is not None:
          return app
  
      conf = conf if conf else settings.MONAI_LABEL_APP_CONF
      logger.info(
          f"Initializing App from: {app_dir}; studies: {studies}; conf: {conf}"
      )
  
      main_py = os.path.join(app_dir, "main.py")
      if not os.path.exists(main_py):
          raise MONAILabelException(
              MONAILabelError.APP_INIT_ERROR,
              "App Does NOT have main.py",
          )
  
      c = get_class_of_subclass_from_file(
          "main", main_py, "MONAILabelApp"
      )
      if c is None:
          raise MONAILabelException(
              MONAILabelError.APP_INIT_ERROR,
              "App Does NOT Implement MONAILabelApp in main.py",
          )
  
      app = c(app_dir=app_dir, studies=studies, conf=conf)
      apps[cache_key] = app
      return app
  
file_path: MONAILabel/monailabel/interfaces/utils/app.py
imports: import argparse
  import json
  import logging
  import os
  from typing import Any, Dict
  from monailabel.config import settings
  from monailabel.interfaces.exception import MONAILabelError, MONAILabelException
  from monailabel.utils.others.class_utils import get_class_of_subclass_from_file
label_desc: Use image node_id 1 for calling a global function with example usage: app_instance(app_dir, studies, conf) and returns: app, app