def preprocess_display(x, transpose=(1, 2, 0), scale=255.0, offset=0.0):
    """Basic preprocessing that reshapes, transposes, and scales an image"""
    x = (x + offset) * scale
    if transpose is not None:
        x = x.transpose(transpose)
    if x.shape[-1] == 1:
        x = x[..., 0]
    return x.clip(0, 255).astype('uint8')
