code: def _find_versioned_file(
      base_paths,
      relative_paths,
      filepatterns,
      required_version,
      get_version,
  ):
      """Returns first valid path to a file that matches the requested version."""
      if type(filepatterns) not in [list, tuple]:
          filepatterns = [filepatterns]
      for path in _cartesian_product(base_paths, relative_paths):
          for filepattern in filepatterns:
              for file in glob.glob(os.path.join(path, filepattern)):
                  actual_version = get_version(file)
                  if _matches_version(actual_version, required_version):
                      return file, actual_version
      raise _not_found_error(
          base_paths,
          relative_paths,
          ", ".join(filepatterns)
          + " matching version '%s'" % required_version,
      )
  
imports: import io
  import os
  import glob
  import platform
  import re
  import subprocess
  import sys
label_desc: Use image node_id 15 for calling a global function with example usage: _find_versioned_file(base_paths, relative_paths, filepatterns, required_version, get_version) and returns: file,  actual_version