class_docstr:     apply contrastive loss but mine the negative sample in the batch.
  apply a mask if the distance between negative pair is too close.
  Parameters
  ----------
  pos_thresh:
      positive threshold of the positive distance
  neg_thresh:
      negative threshold of the negative distance
  min_dist:
      minimum distance to be in the negative sample
class_docstr_tok: ["apply","contrastive","loss","but","mine","the","negative","sample","in","the","batch",".","apply","a","mask","if","the","distance","between","negative","pair","is","too","close",".","Parameters","--","--","--","--","--","pos_thresh",":","positive","threshold","of","the","positive","distance","neg_thresh",":","negative","threshold","of","the","negative","distance","min_dist",":","minimum","distance","to","be","in","the","negative","sample"]
code: def forward(self, F0, F1, positive_pairs, xyz0=None, xyz1=None):
      posF0 = F0[positive_pairs[:, 0]]
      posF1 = F1[positive_pairs[:, 1]]
  
      subxyz0 = xyz0[positive_pairs[:, 0]]
      false_negative = (
          pdist(subxyz0, subxyz0, dist_type="L2") > self.min_dist
      )
      # dists = pdist(posF0, posF1, dist_type="L2").view(-1)
      furthest_pos, _ = (posF0 - posF1).pow(2).max(1)
      neg_loss = F.relu(
          self.neg_thresh
          - (posF0[0] - posF1[false_negative[0]]).pow(2).sum(1).min()
      ).pow(2) / len(posF0)
  
      for i in range(1, len(posF0)):
          neg_loss += F.relu(
              self.neg_thresh
              - (posF0[i] - posF1[false_negative[i]])
              .pow(2)
              .sum(1)
              .min()
          ).pow(2) / len(posF0)
  
      pos_loss = F.relu(furthest_pos - self.pos_thresh).pow(2)
      # neg_loss = F.relu(self.neg_thresh - closest_neg)
      return pos_loss.mean() + neg_loss.mean()
  
file_path: torch-points3d/torch_points3d/core/losses/metric_losses.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  import numpy
label_desc: Use image node_id 2 for calling the BatchHardContrastiveLoss obj's underlying member method code with example usage: obj.forward(F0, F1, positive_pairs, xyz0, xyz1) and returns: unknown