code: def _process_file(model, file_path: Path, out_format: str) -> None:
      if out_format not in ["txt", "json", "xml"]:
          raise ValueError(f"Unsupported output format: {out_format}")
  
      if os.path.splitext(file_path)[1] in IMAGE_FILE_EXTENSIONS:
          doc = DocumentFile.from_images([file_path])
      elif os.path.splitext(file_path)[1] in OTHER_EXTENSIONS:
          doc = DocumentFile.from_pdf(file_path)
      else:
          print(f"Skip unsupported file type: {file_path}")
  
      out = model(doc)
  
      if out_format == "json":
          output = json.dumps(out.export(), indent=2)
      elif out_format == "txt":
          output = out.render()
      elif out_format == "xml":
          output = out.export_as_xml()
  
      path = Path("output").joinpath(file_path.stem + "." + out_format)
      if out_format == "xml":
          for i, (xml_bytes, xml_tree) in enumerate(output):
              path = Path("output").joinpath(
                  file_path.stem + f"_{i}." + out_format
              )
              xml_tree.write(
                  path, encoding="utf-8", xml_declaration=True
              )
      else:
          with open(path, "w") as f:
              f.write(output)
  
file_path: doctr/scripts/detect_text.py
imports: import argparse
  import json
  import os
  from pathlib import Path
  from tqdm import tqdm
  from doctr.file_utils import is_tf_available
  from doctr.io import DocumentFile
  from doctr.models import detection, ocr_predictor
label_desc: Use image node_id 1 for calling a global function with example usage: _process_file(model, file_path, out_format) without return types