code: def compareMatchingFiles(
      name: str,
      nameToHashes1: Dict[str, List[str]],
      nameToHashes2: Dict[str, List[str]],
      args,
  ) -> ComparisonResult:
      """
      Compare files with the given name in all hashes in both paths
      Return the first mismatching files as a tuple (file1, file2), otherwise, return an empty tuple
      """
      hashes1 = nameToHashes1.get(name, [])
      hashes2 = nameToHashes2.get(name, [])
      diffs = []
      errors = []
      numComparisons = 0
      for hash1 in hashes1:
          path1 = os.path.join(args.path1, hash1)
          for hash2 in hashes2:
              path2 = os.path.join(args.path2, hash2)
              # check whether both paths have:
              # 1. json files that match
              # 2. ttir files that match (if they exist), otherwise ttgir files that match (if they exist)
              # if any of these constraints are not met, then we can skip this pair of hashes since they are not a match
              if not doFilesMatch(path1, path2):
                  continue
              numComparisons += 1
              extFile1 = listFilesWithExtension(path1, "ptx")[0]
              extFile2 = listFilesWithExtension(path2, "ptx")[0]
              diff = diffFiles(extFile1, extFile2)
              if len(diff) > 0:
                  diffs.append(diffFiles(extFile2, extFile1))
      if numComparisons == 0:
          errors.append(f"Did not find any matching files for {name}")
      return ComparisonResult(
          name=name,
          numComparisons=numComparisons,
          diffs=diffs,
          errors=errors,
      )
  
imports: import argparse
  import difflib
  import glob
  import os
  import sys
  from typing import Dict, List, Optional, Tuple
  import yaml
label_desc: Use image node_id 9 for calling a global function with example usage: compareMatchingFiles(name, nameToHashes1, nameToHashes2, args) and returns: ComparisonResult