class_docstr: P2SGradLoss() MSE loss between output and target one-hot vectors
  
  See usage in __doc__ of P2SActivationLayer
class_docstr_tok: ["P2SGradLoss","(",")","MSE","loss","between","output","and","target","one-hot","vectors","See","usage","in","__doc__","of","P2SActivationLayer"]
docstr: input
  -----
    input_score: tensor (batch_size, class_num)
           cos \theta given by P2SActivationLayer(input_feat)
    target: tensor (batch_size)
           target[i] is the target class index of the i-th sample
  
  output
  ------
    loss: scaler
docstr_tok: ["input","--","--","-","input_score",":","tensor","(","batch_size",",","class_num",")","cos","\\theta","given","by","P2SActivationLayer","(","input_feat",")","target",":","tensor","(","batch_size",")","target","[","i","]","is","the","target","class","index","of","the","i-th","sample","output","--","--","--","loss",":","scaler"]
code: def forward(self, input_score, target):
      r"""
      input
      -----
        input_score: tensor (batch_size, class_num)
               cos \theta given by P2SActivationLayer(input_feat)
        target: tensor (batch_size)
               target[i] is the target class index of the i-th sample
  
      output
      ------
        loss: scaler
      """
  
      # filling in the target
      # index (batch_size, class_num)
      with torch.no_grad():
          index = torch.zeros_like(input_score)
          index = c_f.to_device(
              index, tensor=input_score, dtype=torch.long
          )
          target = c_f.to_device(
              target, tensor=input_score, dtype=torch.long
          )
          # index[i][target[i][j]] = 1
          index.scatter_(1, target.data.view(-1, 1), 1)
  
      # MSE between \cos\theta and one-hot vectors
      index = index.to(input_score.dtype)
      loss = self.m_loss(input_score, index)
  
      return loss
  
file_path: pytorch-metric-learning/tests/losses/test_p2s_grad_loss.py
imports: import unittest
  import torch
  import torch.nn
  from pytorch_metric_learning.losses import P2SGradLoss
  from pytorch_metric_learning.utils import common_functions
  from ..None import TEST_DEVICE, TEST_DTYPES
label_desc: Use image node_id 2 for calling the TrustedImplementationP2SGradLoss obj's underlying member method code with example usage: obj.forward(input_score, target) and returns: loss