import torch


def minmax_scale_batch(x: torch.Tensor) -> torch.Tensor:
    """rescale a batch of image PyTorch tensors to be between 0 and 1"""
    dims = list(range(1, x.dim()))
    xmin = x.amin(dim=dims, keepdim=True)
    xmax = x.amax(dim=dims, keepdim=True)
    return (x - xmin) / (xmax - xmin)