code: def find_hard_negatives(dmat):
      """
      a = A * P'
      A: N * ndim
      P: N * ndim
  
      a1p1 a1p2 a1p3 a1p4 ...
      a2p1 a2p2 a2p3 a2p4 ...
      a3p1 a3p2 a3p3 a3p4 ...
      a4p1 a4p2 a4p3 a4p4 ...
      ...  ...  ...  ...
      """
  
      pos = dmat.diag()
      dmat.fill_diagonal_(np.inf)
  
      min_a, _ = torch.min(dmat, dim=0)
      min_p, _ = torch.min(dmat, dim=1)
      neg = torch.min(min_a, min_p)
      return pos, neg
  
file_path: pytorch-metric-learning/src/pytorch_metric_learning/losses/dynamic_soft_margin_loss.py
imports: import numpy
  import torch
  from ..distances import LpDistance
  from ..utils import common_functions
  from ..utils import loss_and_miner_utils
  from .base_metric_loss_function import BaseMetricLossFunction
label_desc: Use image node_id 1 for calling a global function with example usage: find_hard_negatives(dmat) and returns: pos,  neg