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 update_histogram(self, data):
      idx, alpha = torch.floor((data - self.min_val) / self.delta).to(
          dtype=torch.long
      ), torch.frac((data - self.min_val) / self.delta)
      momentum = self.momentum if self.hist_.sum() != 0 else 1.0
      self.hist_ = torch.scatter_add(
          (1.0 - momentum) * self.hist_, 0, idx, momentum * (1 - alpha)
      )
      self.hist_ = torch.scatter_add(
          self.hist_, 0, idx + 1, momentum * alpha
      )
      self.hist_ /= self.hist_.sum()
  
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 5 for calling the DynamicSoftMarginLoss obj's underlying member method code with example usage: obj.update_histogram(data) without return types