code: def filter_hunks_by_path(
      hunks: Iterable[diff_parser.Hunk],
      *,
      path_regexes: list[str],
      path_regex_exclusions: list[str],
  ) -> list[diff_parser.Hunk]:
      """Filters files according to path_regexes.
  
      If a file matches both a path_regex and a path_regex_exclusion, then
      it will be filtered out.
  
      Arguments:
        hunks: A sequence of Hunk objects representing the hunks of the diff in the
          change.
        path_regexes: A list of regexes. Paths matching these will pass through the
          filter. By default, every path is matched.
        path_regex_exclusions: A list of regexes. Paths that match both a path_regex
          and a path_regex_exclusion won't pass through the filter.
  
      Returns:
        A list of FileDiffs whose paths match a path_regex and don't match
          any path_regex_exclusions.
      """
  
      if not path_regexes:
          path_regexes = [".*"]  # by default match everything
  
      path_regexes = [re.compile(regex) for regex in path_regexes]
  
      def should_include(path: str) -> bool:
          return any(regex.search(path) for regex in path_regexes)
  
      path_regex_exclusions = [
          re.compile(regex) for regex in path_regex_exclusions
      ]
  
      def should_exclude(path: str) -> bool:
          return any(
              regex.search(path) for regex in path_regex_exclusions
          )
  
      return [
          hunk
          for hunk in hunks
          if should_include(hunk.file) and not should_exclude(hunk.file)
      ]
  
file_path: tensorflow/third_party/xla/build_tools/lint/check_contents.py
imports: import argparse
  import dataclasses
  import logging
  import re
  import sys
  from typing import Iterable, Sequence
  from xla.build_tools.lint import diff_parser
label_desc: Use image node_id 1 for calling a global function with example usage: filter_hunks_by_path(hunks) and returns: unknown, any, any