code: def _get_brew_versions():
      
      from bcbio import install
      tooldir = install.get_defaults().get("tooldir")
      brew_cmd = os.path.join(tooldir, "bin", "brew") if tooldir else "brew"
      try:
          vout = subprocess.check_output([brew_cmd, "list", "--versions"])
      except OSError:  # brew not installed/used
          vout = ""
      out = {}
      for vstr in vout.split("\n"):
          if vstr.strip():
              parts = vstr.rstrip().split()
              name = parts[0]
              v = parts[-1]
              out[name] = v
      return out
docs: Retrieve versions of tools installed via brew.