def clipping(X, lo, hi):
    """
    Helper function for clipping.

    Args:
    -- X: Pytorch tensor of shape (N, C, H, W)
    -- lo: list, lower bound for each channel
    -- hi: list, upper bound for each channel

    Returns:
    -- X: Pytorch tensor of shape (N, C, H, W)
    """
    for c in range(3):
        X.data[:, c].clamp_(min=lo[c], max=hi[c])
    return X