def METHOD_NAME(data, device, non_blocking=False):
    def to_device(data, device, non_blocking=False):
        if device == "pin":
            data = data.pin_memory()
        else:
            data = data.to(device, non_blocking=non_blocking)
        return data
    return recursively_apply(to_device, data, device, non_blocking=non_blocking)