class_docstr: Loss function with dynamical margin parameter introduced in https://openaccess.thecvf.com/content_ICCV_2019/papers/Zhang_Learning_Local_Descriptors_With_a_CDF-Based_Dynamic_Soft_Margin_ICCV_2019_paper.pdf
  
  Args:
      min_val: minimum significative value for `d_pos - d_neg`
      num_bins: number of equally spaced bins for the partition of the interval [min_val, :math:`+\infty`]
      momentum: weight assigned to the histogram computed from the current batch
class_docstr_tok: ["Loss","function","with","dynamical","margin","parameter","introduced","in","https",":","\/\/openaccess.thecvf.com\/content_ICCV_2019\/papers\/Zhang_Learning_Local_Descriptors_With_a_CDF-Based_Dynamic_Soft_Margin_ICCV_2019_paper.pdf","Args",":","min_val",":","minimum","significative","value","for","`","d_pos","-","d_neg","`","num_bins",":","number","of","equally","spaced","bins","for","the","partition","of","the","interval","[","min_val",",",":","math",":","`","+\\infty","`","]","momentum",":","weight","assigned","to","the","histogram","computed","from","the","current","batch"]
code: def compute_loss(
      self, embeddings, labels, indices_tuple, ref_emb, ref_labels
  ):
      self.hist_ = c_f.to_device(
          self.hist_, tensor=embeddings, dtype=embeddings.dtype
      )
  
      if labels is None:
          loss = self.compute_loss_without_labels(
              embeddings, labels, indices_tuple, ref_emb, ref_labels
          )
      else:
          loss = self.compute_loss_with_labels(
              embeddings, labels, indices_tuple, ref_emb, ref_labels
          )
  
      if len(loss) == 0:
          return self.zero_losses()
  
      self.update_histogram(loss)
      loss = self.weigh_loss(loss)
      loss = loss.mean()
      return {
          "loss": {
              "losses": loss,
              "indices": None,
              "reduction_type": "already_reduced",
          }
      }
  
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 2 for calling the DynamicSoftMarginLoss obj's underlying member method code with example usage: obj.compute_loss(embeddings, labels, indices_tuple, ref_emb, ref_labels) and returns: dict, self