def rescale(tensor, max_, min_):
    """ Rescale a pytorch tensor to [0,1].
    tensor: pytorch tensor with dimensions [batch,channels,width,height]
    max_: pytorch tensor containing the maximum values per channel
    min_: pytorch tensor containing the minimum values per channel
    outputs -> rescaled pytorch tensor with the same dimensions as 'tensor'
    """
    max_ = max_.reshape(1, -1, 1, 1)
    min_ = min_.reshape(1, -1, 1, 1)
    return (tensor - min_) / (max_ - min_ + 1e-8)