code: def forward(self, feature, label=None) -> Tensor:
      # Dual-Path Convolutional Image-Text Embeddings with Instance Loss, ACM TOMM 2020
      # https://zdzheng.xyz/files/TOMM20.pdf
      # using cross-entropy loss for every sample if label is not available. else use given label.
      normed_feature = l2_norm(feature)
      sim1 = torch.mm(
          normed_feature * self.gamma, torch.t(normed_feature)
      )
      # sim2 = sim1.t()
      if label is None:
          sim_label = torch.arange(sim1.size(0)).cuda().detach()
      else:
          _, sim_label = torch.unique(label, return_inverse=True)
      loss = F.cross_entropy(
          sim1, sim_label
      )  # + F.cross_entropy(sim2, sim_label)
      return loss
  
file_path: pytorch-metric-learning/tests/losses/test_instance_loss.py
imports: import unittest
  import numpy
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from pytorch_metric_learning.losses import InstanceLoss
  from ..None import TEST_DEVICE, TEST_DTYPES
label_desc: Use image node_id 2 for calling the OriginalInstanceLoss obj's underlying member method code with example usage: obj.forward(feature, label) and returns: loss