class_docstr: Output layer that produces cos  heta between activation vector x
  and class vector w_j
  
  in_dim:     dimension of input feature vectors
  output_dim: dimension of output feature vectors
              (i.e., number of classes)
  
  Usage example:
    batch_size = 64
    input_dim = 10
    class_num = 5
  
    l_layer = P2SActivationLayer(input_dim, class_num)
    l_loss = P2SGradLoss()
  
    data = torch.rand(batch_size, input_dim, requires_grad=True)
    target = (torch.rand(batch_size) * class_num).clamp(0, class_num-1)
    target = target.to(torch.long)
  
    scores = l_layer(data)
    loss = l_loss(scores, target)
  
    loss.backward()
class_docstr_tok: ["Output","layer","that","produces","cos","heta","between","activation","vector","x","and","class","vector","w_j","in_dim",":","dimension","of","input","feature","vectors","output_dim",":","dimension","of","output","feature","vectors","(","i.e.",",","number","of","classes",")","Usage","example",":","batch_size","=","64","input_dim","=","10","class_num","=","5","l_layer","=","P2SActivationLayer","(","input_dim",",","class_num",")","l_loss","=","P2SGradLoss","(",")","data","=","torch.rand","(","batch_size",",","input_dim",",","requires_grad=True",")","target","=","(","torch.rand","(","batch_size",")","*","class_num",")",".clamp","(","0",",","class_num-1",")","target","=","target.to","(","torch.long",")","scores","=","l_layer","(","data",")","loss","=","l_loss","(","scores",",","target",")","loss.backward","(",")"]
code: def __init__(self, in_dim, out_dim):
      super(TrustedImplementationP2SActivationLayer, self).__init__()
      self.in_dim = in_dim
      self.out_dim = out_dim
  
      self.weight = nn.Parameter(
          torch.Tensor(in_dim, out_dim), requires_grad=True
      )
      self.weight.data.uniform_(-1, 1).renorm_(2, 1, 1e-5).mul_(1e5)
      return
  
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 1 to create a new TrustedImplementationP2SActivationLayer object from inherited base classes: nn with example: obj = TrustedImplementationP2SActivationLayer(in_dim, out_dim)