code: def run_flake8_for_dir(
      flake8_bin: str,
      source_root: str,
      config: str,
      check_files: list[str],
  ) -> dict[str, list[str]]:
      with tempfile.TemporaryDirectory() as temp_dir:
          logger.debug("flake8 temp dir: %s", temp_dir)
          for f in check_files:
              copy_file_path = os.path.join(
                  temp_dir, os.path.relpath(f, source_root)
              )
              os.makedirs(
                  os.path.dirname(copy_file_path), exist_ok=True
              )
              shutil.copyfile(f, copy_file_path)
          flake8_res = run_flake8(flake8_bin, temp_dir, config)
          return get_flake8_results(flake8_res, source_root, temp_dir)
  
imports: import configparser
  import hashlib
  import itertools
  import io
  import logging
  import os
  import re
  import shutil
  import subprocess
  import sys
  import tempfile
  from collections import defaultdict
  from typing import Generator
  from devtools.ya.test.programs.test_tool.lib.migrations_config import load_yaml_config, MigrationsConfig
  from library.python.testing.custom_linter_util import linter_params, reporter
  from build.plugins.lib.test_const import FLAKE8_PY2_RESOURCE, FLAKE8_PY3_RESOURCE
label_desc: Use image node_id 7 for calling a global function with example usage: run_flake8_for_dir(flake8_bin, source_root, config, check_files) and returns: get_flake8_results