code: def run_wsi_inference(
      background_tasks: BackgroundTasks,
      model: str,
      image: str = "",
      session_id: str = "",
      file: Union[UploadFile, None] = None,
      wsi: WSIInput = WSIInput(),
      output: Optional[ResultType] = ResultType.dsa,
  ):
      request = {
          "model": model,
          "image": image,
          "output": output.value if output else None,
      }
  
      if not file and not image and not session_id:
          raise HTTPException(
              status_code=500,
              detail="Neither Image nor File not Session ID input is provided",
          )
  
      instance: MONAILabelApp = app_instance()
  
      if file and file.filename:
          file_ext = (
              "".join(pathlib.Path(file.filename).suffixes)
              if file.filename
              else ".png"
          )
          image_file = tempfile.NamedTemporaryFile(suffix=file_ext).name
  
          with open(image_file, "wb") as buffer:
              shutil.copyfileobj(file.file, buffer)
              request["image"] = image_file
              background_tasks.add_task(remove_file, image_file)
  
      config = instance.info().get("config", {}).get("infer", {})
      request.update(config)
      request.update(wsi.dict(exclude={"params"}))
      if wsi.params:
          request.update(wsi.params)
  
      if session_id:
          session = instance.sessions().get_session(session_id)
          if session:
              request["image"] = session.image
              request["session"] = session.to_json()
  
      logger.info(f"WSI Infer Request: {request}")
  
      result = instance.infer_wsi(request)
      if result is None:
          raise HTTPException(
              status_code=500, detail="Failed to execute wsi infer"
          )
      return send_response(
          instance.datastore(), result, output, background_tasks
      )
  
imports: import json
  import logging
  import os
  import pathlib
  import shutil
  import tempfile
  from enum import Enum
  from typing import Optional, Sequence, Union
  from fastapi import APIRouter, Depends, File, Form, HTTPException, UploadFile
  from fastapi.background import BackgroundTasks
  from fastapi.responses import FileResponse
  from pydantic import BaseModel, Field
  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
  from monailabel.utils.others.generic import get_mime_type, remove_file
label_desc: Use image node_id 2 for calling a global function with example usage: run_wsi_inference(background_tasks, model, image, session_id, file, wsi, output) and returns: send_response