docstr: fvec : B1 x D , current batch of feature embedding
  fLvec : B1 , current batch of GT labels
  fvecs_add : B2 x D , batch of additionnal contextual features to fill the manifold
docstr_tok: ["fvec",":","B1","x","D",",","current","batch","of","feature","embedding","fLvec",":","B1",",","current","batch","of","GT","labels","fvecs_add",":","B2","x","D",",","batch","of","additionnal","contextual","features","to","fill","the","manifold"]
code: def forward(self, fvec, fLvec, fvecs_add=None):
      """
      fvec : B1 x D , current batch of feature embedding
      fLvec : B1 , current batch of GT labels
      fvecs_add : B2 x D , batch of additionnal contextual features to fill the manifold
      """
      fLvec = fLvec.tolist()
      N = len(fLvec)
  
      if fvecs_add is not None:
          fvec = torch.cat((fvec, self.proxy, fvecs_add), 0)
      else:
          fvec = torch.cat((fvec, self.proxy), 0)
      # normalization (as in the original proxy method)
      fvec = fvec / fvec.norm(p=2, dim=1).view(-1, 1)
  
      # Rank matrix
      A = self.get_Matrix(fvec)
      A_p = A[N : N + self.nb_proxy].clone()
      A = A[:N]
      loss_intrinsic = torch.zeros(
          1, dtype=fvec.dtype, device=fvec.device
      )  # Modified to avoid errors
      loss_context = torch.zeros(
          1, dtype=fvec.dtype, device=fvec.device
      )  # Modified to avoid errors
  
      for i in range(N):
          loss_neg1_intrinsic = torch.zeros(
              1, dtype=fvec.dtype, device=fvec.device
          )  # Removed .cuda() to avoid errors                                   # NoQA
          loss_neg1_context = torch.zeros(
              1, dtype=fvec.dtype, device=fvec.device
          )  # Removed .cuda() to avoid errors                                   # NoQA
          dist_pos = self.d(
              torch.unsqueeze(A[i], 0),
              torch.unsqueeze(A_p[fLvec[i]], 0),
          )
  
          for j in range(self.nb_proxy):
              if fLvec[i] != j:
                  val1_context = (
                      self.d(
                          torch.unsqueeze(A[i], 0),
                          torch.unsqueeze(A_p[j], 0),
                      )
                      - dist_pos
                  )
                  val1_intrinsic = A[i, N + j] - A[i, N + fLvec[i]]
                  if val1_context > 0:
                      loss_neg1_context += torch.exp(val1_context)
                  if val1_intrinsic > 0:
                      loss_neg1_intrinsic += torch.exp(val1_intrinsic)
  
          loss_intrinsic += torch.log(
              1.0 + loss_neg1_intrinsic
          )  # + torch.log(torch.add(loss_neg2_intrinsec, 1.0))
          loss_context += torch.log(
              1.0 + loss_neg1_context
          )  # + torch.log(torch.add(loss_neg2_context, 1.0))
  
      loss_intrinsic /= N
      loss_context /= N
  
      return loss_intrinsic + self.lambdaC * loss_context
  
file_path: pytorch-metric-learning/tests/losses/test_manifold_loss.py
imports: import unittest
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.modules.module import Module
  from pytorch_metric_learning.losses import ManifoldLoss
  from ..None import TEST_DEVICE, TEST_DTYPES
label_desc: Use image node_id 3 for calling the OriginalImplementationManifoldLoss obj's underlying member method code with example usage: obj.forward(fvec, fLvec, fvecs_add) and returns: unknown