Implement a solution for a common data structure manipulation (e.g., linked lists, trees, or graphs). For this task, reverse a singly linked list in place and return its new head. Use reverse_list(head), where head is a ListNode with value and next fields; the test harness represents lists as arrays and serializes the returned list as an array. Preserve all nodes and use constant auxiliary space.
def reverse_list(head):