code: def parse_aquery_output_artifacts(aquery_results):
      """Extracts and yields the file paths representing the output artifact
      from the provided Bazel aquery results.
  
      To understand the output of aquery command in textproto format, try:
          bazel aquery --include_artifacts=true --output=jsonproto \
              'mnemonic("Genrule", deps(//:*))'
      """
      fragments = {}
      for fragment in aquery_results["pathFragments"]:
          fragments[fragment["id"]] = fragment
  
      artifacts = {}
      for artifact in aquery_results["artifacts"]:
          artifacts[artifact["id"]] = artifact
  
      def _path(fragment_id):
          fragment = fragments[fragment_id]
          parent = (
              _path(fragment["parentId"])
              if "parentId" in fragment
              else []
          )
          return parent + [fragment["label"]]
  
      for action in aquery_results["actions"]:
          for output_id in action["outputIds"]:
              path = os.path.join(
                  *_path(artifacts[output_id]["pathFragmentId"])
              )
              yield path
  
imports: import ast
  import errno
  import json
  import os
  import re
  import subprocess
  import stat
  import sys
  from collections import defaultdict, OrderedDict
label_desc: Use image node_id 5 for calling a global function with example usage: parse_aquery_output_artifacts(aquery_results) and returns: unknown