class_docstr: FileTypeRouter takes a list of data sources (file paths or byte streams) and groups them by their corresponding
  MIME types. For file paths, MIME types are inferred from their extensions, while for byte streams, MIME types
  are determined from the provided metadata.
  
  The set of MIME types to consider is specified during the initialization of the component.
  
  This component is invaluable when categorizing a large collection of files or data streams by their MIME
  types and routing them to different components for further processing.
class_docstr_tok: ["FileTypeRouter","takes","a","list","of","data","sources","(","file","paths","or","byte","streams",")","and","groups","them","by","their","corresponding","MIME","types",".","For","file","paths",",","MIME","types","are","inferred","from","their","extensions",",","while","for","byte","streams",",","MIME","types","are","determined","from","the","provided","metadata",".","The","set","of","MIME","types","to","consider","is","specified","during","the","initialization","of","the","component",".","This","component","is","invaluable","when","categorizing","a","large","collection","of","files","or","data","streams","by","their","MIME","types","and","routing","them","to","different","components","for","further","processing","."]
docstr: Initialize the FileTypeRouter.
  
  :param mime_types: A list of file mime types to consider when routing
  files (e.g. ["text/plain", "audio/x-wav", "image/jpeg"]).
docstr_tok: ["Initialize","the","FileTypeRouter",".",":","param","mime_types",":","A","list","of","file","mime","types","to","consider","when","routing","files","(","e.g",".","[","``","text\/plain","''",",","``","audio\/x-wav","''",",","``","image\/jpeg","''","]",")","."]
code: def __init__(self, mime_types: List[str]):
      """
      Initialize the FileTypeRouter.
  
      :param mime_types: A list of file mime types to consider when routing
      files (e.g. ["text/plain", "audio/x-wav", "image/jpeg"]).
      """
      if not mime_types:
          raise ValueError("The list of mime types cannot be empty.")
  
      for mime_type in mime_types:
          if not self.is_valid_mime_type_format(mime_type):
              raise ValueError(
                  f"Unknown mime type: '{mime_type}'. Ensure you passed a list of strings in the 'mime_types' parameter"
              )
  
      component.set_output_types(
          self,
          unclassified=List[Path],
          **{mime_type: List[Path] for mime_type in mime_types},
      )
      self.mime_types = mime_types
  
file_path: haystack/haystack/components/routers/file_type_router.py
imports: import logging
  import mimetypes
  from collections import defaultdict
  from pathlib import Path
  from typing import List, Union, Optional, Dict
  from haystack import component
  from haystack.dataclasses import ByteStream
label_desc: Use image node_id 1 to create a new FileTypeRouter object  with example: obj = FileTypeRouter(mime_types)