<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sum_dice(spec):
 """ Replace the dice roll arrays from roll_dice in place with summations of the rolls. """

    if spec[0] == 'c': return spec[1]
    elif spec[0] == 'r': return sum(spec[1])
    elif spec[0] == 'x':
        return [sum_dice(r) for r in spec[1]]
    elif spec[0] in ops:
        return (spec[0], sum_dice(spec[1]), sum_dice(spec[2]))
    else: raise ValueError("Invalid dice specification")