Design an in-memory data structure that can efficiently track and update supply chain inventory levels across multiple nodes.
Implement inventory_operations(operations). Each operation is a dictionary representing an inventory update, transfer, or query. Return query results in encounter order. Support update, transfer, stock, total, and node_total operations. Inventory quantities must never become negative, and all operation inputs are valid.
update changes one SKU at one node by a signed delta. transfer moves a positive quantity between two nodes. Query operations return integer quantities.
def inventory_operations(operations):