class_docstr: Args:
      margin: The desired difference between the anchor-positive distance and the
              anchor-negative distance.
      swap: Use the positive-negative distance instead of anchor-negative distance,
            if it violates the margin more.
      smooth_loss: Use the log-exp version of the triplet loss
code: def __init__(
      self,
      margin=0.05,
      swap=False,
      smooth_loss=False,
      triplets_per_anchor="all",
      **kwargs,
  ):
      super().__init__(**kwargs)
      self.margin = margin
      self.swap = swap
      self.smooth_loss = smooth_loss
      self.triplets_per_anchor = triplets_per_anchor
      self.add_to_recordable_attributes(
          list_of_names=["margin"], is_stat=False
      )
  
file_path: pytorch-metric-learning/src/pytorch_metric_learning/losses/triplet_margin_loss.py
imports: import torch
  from ..reducers import AvgNonZeroReducer
  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 to create a new TripletMarginLoss object from inherited base classes: BaseMetricLossFunction with example: obj = TripletMarginLoss(margin, swap, smooth_loss, triplets_per_anchor)