def detach(hidden):
if isinstance(hidden, (tuple, list)):<EOL><INDENT>hidden = [detach(h) for h in hidden]<EOL><DEDENT>else:<EOL><INDENT>hidden = hidden.detach()<EOL><DEDENT>return hidden<EOL>
Transfer hidden states into new states, to detach them from the history.
    Parameters
    ----------
    hidden : NDArray
        The hidden states
    Returns
    ----------
    hidden: NDArray
        The detached hidden states