class_docstr: Implementation of https://arxiv.org/pdf/1612.02295.pdf
class_docstr_tok: ["Implementation","of","https",":","\/\/arxiv.org\/pdf\/1612.02295.pdf"]
code: def init_margin(self):
      self.margin = int(self.margin)
      self.max_n = self.margin // 2
      ## For the trigonometric multiple-angle formula ##
      self.n_range = torch.tensor([n for n in range(0, self.max_n + 1)])
      self.margin_choose_n = torch.tensor(
          [
              scipy.special.binom(self.margin, 2 * n)
              for n in self.n_range
          ]
      )
      self.cos_powers = torch.tensor(
          [self.margin - (2 * n) for n in self.n_range]
      )
      self.alternating = torch.tensor([(-1) ** n for n in self.n_range])
  
imports: import math
  import numpy
  import scipy.special
  import torch
  from ..distances import CosineSimilarity
  from ..utils import common_functions
  from ..utils import loss_and_miner_utils
  from .base_metric_loss_function import BaseMetricLossFunction
  from .mixins import WeightRegularizerMixin
label_desc: Use image node_id 2 for calling the LargeMarginSoftmaxLoss obj's underlying member method code with example usage: obj.init_margin() without return types