I think I expressed it wrong. actually, i have masking image (3xwxh).  tried combining all the masked pictures for example
(tab is not important)
image = np.zeros((predicted.size()[0],224,224))
            for i in range(predicted.size()[0]): # i is a batch 
              for j in range(predicted.size()[1]): # j is a masking dim 
                image[i] += predicted[i,j].detach().numpy()
            predicted = torch.tensor(image,requires_grad=True)