code: def _assign_files_to_readers(
      files_to_sort, reader_names, reader_kwargs  # noqa: D417
  ):
      """Assign files to readers.
  
      Given a list of file names (paths), match those to reader instances.
  
      Internal helper for group_files.
  
      Args:
          files_to_sort (Collection[str]): Files to assign to readers.
          reader_names (Collection[str]): Readers to consider
          reader_kwargs (Mapping):
  
      Returns:
          Mapping[str, Tuple[reader, Set[str]]]
          Mapping where the keys are reader names and the values are tuples of
          (reader_configs, filenames).
      """
      files_to_sort = set(files_to_sort)
      reader_dict = {}
      for reader_configs in configs_for_reader(reader_names):
          try:
              reader = load_reader(reader_configs, **reader_kwargs)
          except yaml.constructor.ConstructorError:
              LOG.exception(
                  f"ConstructorError loading {reader_configs!s}, "
                  "probably a missing dependency, skipping "
                  "corresponding reader (if you did not explicitly "
                  "specify the reader, Satpy tries all; performance "
                  "will improve if you pass readers explicitly)."
              )
              continue
          reader_name = reader.info["name"]
          files_matching = set(
              reader.filter_selected_filenames(files_to_sort)
          )
          files_to_sort -= files_matching
          if files_matching or reader_names is not None:
              reader_dict[reader_name] = (reader, files_matching)
      if files_to_sort:
          raise ValueError(
              "No matching readers found for these files: "
              + ", ".join(files_to_sort)
          )
      return reader_dict
  
imports: from __future__ import annotations
  import logging
  import os
  import pathlib
  import pickle
  import warnings
  from datetime import datetime, timedelta
  from functools import total_ordering
  import yaml
  from yaml import UnsafeLoader
  from satpy._config import config_search_paths, get_entry_points_config_dirs, glob_config
  from .yaml_reader import AbstractYAMLReader
  from .yaml_reader import load_yaml_configs
label_desc: Use image node_id 2 for calling a global function with example usage: _assign_files_to_readers(files_to_sort, reader_names, reader_kwargs) and returns: reader_dict