code: def sample(
      strategy: str,
      params: Optional[dict] = None,
      user: Optional[str] = None,
  ):
      request = {"strategy": strategy}
  
      instance: MONAILabelApp = app_instance()
      config = (
          instance.info().get("config", {}).get("activelearning", {})
      )
      request.update(config)
  
      params = params if params is not None else {}
      request.update(params)
  
      logger.info(f"Active Learning Request: {request}")
      result = instance.next_sample(request)
      if not result:
          return {}
  
      image_id = result["id"]
      image_info = instance.datastore().get_image_info(image_id)
  
      strategy_info = image_info.get("strategy", {})
      strategy_info[strategy] = {
          "ts": int(time.time()),
          "client_id": params.get("client_id", user),
      }
      try:
          instance.datastore().update_image_info(
              image_id, {"strategy": strategy_info}
          )
      except:
          logger.warning(f"Failed to update Image info for {image_id}")
  
      result.update(image_info)
      logger.info(f"Next sample: {result}")
      return result
  
file_path: MONAILabel/monailabel/endpoints/activelearning.py
imports: import logging
  import time
  from typing import Dict, Optional
  from fastapi import APIRouter, Depends
  from monailabel.config import RBAC_USER, settings
  from monailabel.endpoints.user.auth import RBAC, User
  from monailabel.interfaces.app import MONAILabelApp
  from monailabel.interfaces.utils.app import app_instance
label_desc: Use image node_id 1 for calling a global function with example usage: sample(strategy, params, user) and returns: result, dict