code: def get_output_dir(
      root: Path, basename: str, output_dir_year_month: bool
  ) -> Path:
      if output_dir_year_month:
          today = datetime.today()
          output_directory_year_month = (
              root / str(today.year) / f"{today.month:02d}"
          )
          if not output_directory_year_month.exists():
              output_directory_year_month.mkdir(
                  parents=True, exist_ok=True
              )
          output_path = Path(output_directory_year_month) / basename
      else:
          output_path = root / basename
      return output_path
  
imports: import json
  import logging
  import shutil
  import sys
  import time
  from datetime import datetime
  from enum import Enum
  from pathlib import Path
  from typing import Annotated, Any
  import pikepdf
  import typer
  from dotenv import load_dotenv
  from watchdog.events import PatternMatchingEventHandler
  from watchdog.observers import Observer
  from watchdog.observers.polling import PollingObserver
  import ocrmypdf
label_desc: Use image node_id 1 for calling a global function with example usage: get_output_dir(root, basename, output_dir_year_month) and returns: output_path