Thanks to @ptrblck link I could figure out how to implement my transform. I had to make a few tweaks to transform from PIL image to numpy back and forth but so far it isn’t throwing errors anymore. In case this proves useful for anyone on the future (I know I’d have been that way for me) I will leave my final code below.
class shades_of_gray(object):
   
   #     Parameters
   #    ----------
   #   img: 2D numpy array
   #         The original image with format of (h, w, c)
   #     power: int
   #         The degree of norm, 6 is used in reference paper
   # 
     
    
    def __call__(self, img):
        """
        :param img: PIL): Image 

        :return: Normalized image
        """
        img = numpy.asarray(img)
        img_dtype = img.dtype

        power = 6
        extra = 6

        img = img.astype('float32')
        img_power = numpy.power(img, power)
        rgb_vec = numpy.power(numpy.mean(img_power, (0, 1)), 1 / power)
        rgb_norm = numpy.power(numpy.sum(numpy.power(rgb_vec, extra)), 1 / extra)
        rgb_vec = rgb_vec / rgb_norm
        rgb_vec = 1 / (rgb_vec * numpy.sqrt(3))
        img = numpy.multiply(img, rgb_vec)
        img = img.astype(img_dtype)

        return Image.fromarray(img)

    def __repr__(self):
        return self.__class__.__name__+'()'

If you see anything wrong or have any tips that I could follow, feel free to share them. Also, I don’t fully understand what does the “def repr(self)” line actually do.
Thank you for your time.