code: def _apply_scheme(repo_dir, cmd_template, pattern, ok_errors):
      cmd = [
          _resolve_str(arg).format(repo=repo_dir)
          for arg in cmd_template
      ]
      log.debug("vcs scheme cmd for repo %s: %s", repo_dir, cmd)
      try:
          out = subprocess.check_output(
              cmd,
              cwd=repo_dir,
              env=os.environ,
              stderr=subprocess.STDOUT,
          )
      except OSError as e:
          if e.errno == 2:
              return None
          raise CommitReadError(e) from e
      except subprocess.CalledProcessError as e:
          if e.returncode in ok_errors:
              return None
          raise CommitReadError(e, e.output) from e
      else:
          out = out.decode("ascii", errors="replace")
          log.debug("vcs scheme result: %s", out)
          m = pattern.match(out)
          if not m:
              return None
          return m.group(1)
  
imports: import collections
  import logging
  import re
  import os
  import subprocess
  from guild import config
  from guild import file_util
  from guild import util
  from guild.file_util import FileSelectRule
label_desc: Use image node_id 3 for calling a global function with example usage: _apply_scheme(repo_dir, cmd_template, pattern, ok_errors) and returns: m, None, None, None