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: Categorizes the provided data sources by their MIME types.
  
  :param sources: A list of file paths or byte streams to categorize.
  :return: A dictionary where keys are MIME types and values are lists of data sources.
docstr_tok: ["Categorizes","the","provided","data","sources","by","their","MIME","types",".",":","param","sources",":","A","list","of","file","paths","or","byte","streams","to","categorize",".",":","return",":","A","dictionary","where","keys","are","MIME","types","and","values","are","lists","of","data","sources","."]
code: def run(
      self, sources: List[Union[str, Path, ByteStream]]
  ) -> Dict[str, List[Union[ByteStream, Path]]]:
      """
      Categorizes the provided data sources by their MIME types.
  
      :param sources: A list of file paths or byte streams to categorize.
      :return: A dictionary where keys are MIME types and values are lists of data sources.
      """
  
      mime_types = defaultdict(list)
      for source in sources:
          if isinstance(source, str):
              source = Path(source)
  
          if isinstance(source, Path):
              mime_type = self.get_mime_type(source)
          elif isinstance(source, ByteStream):
              mime_type = source.meta.get("content_type")
          else:
              raise ValueError(
                  f"Unsupported data source type: {type(source)}"
              )
  
          if mime_type in self.mime_types:
              mime_types[mime_type].append(source)
          else:
              mime_types["unclassified"].append(source)
  
      return 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 2 for calling the FileTypeRouter obj's underlying member method code with example usage: obj.run(sources) and returns: mime_types