Thanks for the clarification and it worked. I would like  to examine the performance of an Auto encoder  in MNIST dataset with an addition of extra loss function on mean pixel target. But I calculate the target mean pixels like this .
class MNIST1(dataset.MNIST):
    
    def __getitem__(self, index):
        """
        Args:
            index (int): Index

        Returns:
            tuple: (image, target,mean_pixel) where target is index of the target class.
        """
        img, target = self.data[index], int(self.targets[index])
        

        # doing this so that it is consistent with all other datasets
        # to return a PIL Image
        img = Image.fromarray(img.numpy(), mode='L')
        
        # Calculatine the mean pixel value
        stat = ImageStat.Stat(img)
        mean_pixel = stat.mean
        if self.transform is not None:
            img = self.transform(img)
            
        if self.target_transform is not None:
            target = self.target_transform(target)
        
        
        return img, target,mean_pixel

I have doubt regarding the mean calculation, I am doing it on the PIL image where the pixel value ranges between 0 and 255. However I normalize the input image as follows
trans = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (1.0,))])


If I want to calculate the loss on the mean pixel(assume that we have encoded the  predicted mean pixel value on one of the entries of the encoder decoder bottleneck part) target mean pixel values should be calculated on the normalized input or not?