<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def to_detach(b:Tensors, cpu:bool=True):
    "Recursively detach lists of tensors in `b `; put them on the CPU if `cpu=True`."
    if is_listy(b): return [to_detach(o, cpu) for o in b]
    if not isinstance(b,Tensor): return b
    b = b.detach()
    return b.cpu() if cpu else b