def METHOD_NAME(x, device):
    if x is None:
        return None
    if isinstance(x, list):
        return [METHOD_NAME(y, device) for y in x]
    if isinstance(x, np.ndarray):
        return x
    if device == "cpu":
        return from_dlpack(x).numpy()
    else:
        return from_dlpack(x).cpu().numpy()