code: def git_grep(pattern):
      """Run `git grep` and collect matches.
  
      This function exits the process if `git grep` writes any stderr: for
      instance, if the provided pattern is an invalid regular expression.
  
      Args:
        pattern: `str`; a pattern argument to `git grep`.
  
      Returns:
        A list of `Match` values.
      """
      cmd = ["git", "grep", "-Izn", "--", pattern]
      p = subprocess.Popen(
          cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
      )
      (stdout, stderr) = p.communicate()
      if stderr:
          getattr(sys.stderr, "buffer", sys.stderr).write(
              stderr
          )  # Python 2 compat
          sys.exit(1)
      result = []
      for (
          line
      ) in (
          stdout.splitlines()
      ):  # assumes no newline characters in filenames
          (filename_raw, line_number_raw, line_raw) = line.split(
              b"\0", 2
          )
          match = Match(
              filename=filename_raw.decode("utf-8", errors="replace"),
              line_number=int(line_number_raw),
              line=line_raw.decode("utf-8", errors="replace"),
          )
          result.append(match)
      return result
  
file_path: tensorboard/tensorboard/tools/whitespace_hygiene_test.py
imports: import dataclasses
  import os
  import subprocess
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: git_grep(pattern) and returns: result