Implement a Document class with the following methods: init(), apply(id, property_name, value), undo(), commit_batch(). Update the undo function to undo a batch.
Treat each sequence of apply calls between commit_batch calls as one batch. undo() must reverse the most recently committed batch, restoring overwritten properties and removing newly created properties. For grading, implement run_document(operations), where operations are tuples such as ("apply", id, property_name, value), ("commit_batch",), and ("undo",); return the final document state as a nested dictionary.
def run_document(operations):