keras/src/layers/preprocessing/random_contrast.py/RandomContrast/_adjust_constrast
class RandomContrast:    def _adjust_constrast(self, inputs, contrast_factor):
        # reduce mean on height
        inp_mean = self.backend.numpy.mean(inputs, axis=-3, keepdims=True)
        # reduce mean on width
        inp_mean = self.backend.numpy.mean(inp_mean, axis=-2, keepdims=True)

        outputs = (inputs - inp_mean) * contrast_factor + inp_mean
        return outputs