code: def process_queue(queue: AnnotatedQueue):
      """Process the annotated queue, creating a list of quantum
      operations and measurement processes.
  
      Args:
          queue (.AnnotatedQueue): The queue to be processed into individual lists
  
      Returns:
          tuple[list(.Operation), list(.MeasurementProcess)]:
          The list of tape operations, the list of tape measurements
      """
      lists = {"_ops": [], "_measurements": []}
      list_order = {"_ops": 1, "_measurements": 2}
      current_list = "_ops"
  
      for obj, info in queue.items():
          if (
              "owner" not in info
              and getattr(obj, "_queue_category", None) is not None
          ):
              if (
                  list_order[obj._queue_category]
                  > list_order[current_list]
              ):
                  current_list = obj._queue_category
              elif (
                  list_order[obj._queue_category]
                  < list_order[current_list]
              ):
                  raise ValueError(
                      f"{obj._queue_category[1:]} operation {obj} must occur prior "
                      f"to {current_list[1:]}. Please place earlier in the queue."
                  )
              lists[obj._queue_category].append(obj)
  
      return lists["_ops"], lists["_measurements"]
  
imports: import copy
  from collections import OrderedDict
  from contextlib import contextmanager
  from threading import RLock
  from typing import Optional
label_desc: Use image node_id 2 for calling a global function with example usage: process_queue(queue) and returns: lists,  lists