Solved by Usama_Hasan in post #7 
              
              
                My Bad, I mentioned the forked repo link. Check the loss_function.py in this repo. 
 
 
The calculation looks like this.
numerator = self.s * torch.cos(torch.acos(torch.clamp(torch.diagonal(wf.transpose(0, 1)[labels]), -1.+self.eps, 1-self.eps)) + self.m)