Hi Ptrblck,
Would you please help me with that error regarding backward.() ("RuntimeError: leaf variable has been moved into the graph interior
" )
      bbb=fake.squeeze(1)
        bbb1=MASKGaussy.squeeze(1)
        
        zzz1=torch.zeros(bbb.shape,requires_grad=True)
        zzz=torch.zeros(bbb1.shape,requires_grad=True)

        for ii in range(bbb.shape[0]):
            for ii1 in range(bbb.shape[1]):
                for ii2 in range(bbb.shape[2]):
                    if bbb[ii,ii1,ii2]>=0.99:
                       zzz[ii,ii1,ii2]=1
                    elif  bbb[ii,ii1,ii2]<0.99:
                       zzz[ii,ii1,ii2]=0
            
        for ii in range(bbb1.shape[0]):
            for ii1 in range(bbb1.shape[1]):
                for ii2 in range(bbb1.shape[2]):
                    if bbb1[ii,ii1,ii2]>=0.99:
                       zzz1[ii,ii1,ii2]=1
                    elif  bbb1[ii,ii1,ii2]<0.99:
                        zzz1[ii,ii1,ii2]=0
                        
        L1=nn.MSELoss()(zzz,zzz1)
        loss2=L1
        loss2.backward()