code: def __init__(
      self, weight_regularizer=None, weight_reg_weight=1, **kwargs
  ):
      self.weight_regularizer = (
          weight_regularizer is not None
      )  # hack needed to know whether reg will be in sub-loss names
      super().__init__(**kwargs)
      self.weight_regularizer = weight_regularizer
      self.weight_reg_weight = weight_reg_weight
      if self.weight_regularizer is not None:
          self.add_to_recordable_attributes(
              list_of_names=["weight_reg_weight"], is_stat=False
          )
  
file_path: pytorch-metric-learning/src/pytorch_metric_learning/losses/mixins.py
imports: import torch
  from ..utils import common_functions
label_desc: Use image node_id 1 to create a new WeightRegularizerMixin object from inherited base classes: WeightMixin with example: obj = WeightRegularizerMixin(weight_regularizer, weight_reg_weight)