class_docstr: Author: {Xiang An, Yang Xiao, XuHan Zhu} in DeepGlint,
  Partial FC: Training 10 Million Identities on a Single Machine
  See the original paper:
  https://arxiv.org/abs/2010.05222
code: def __init__(
      self,
      rank,
      world_size,
      num_classes,
      margin1=1.0,
      margin2=0.5,
      margin3=0.0,
      scale=64.0,
      sample_ratio=1.0,
      embedding_size=512,
      fp16=False,
      name=None,
  ):
      super(LargeScaleClassifier, self).__init__()
      self.num_classes: int = num_classes
      self.rank: int = rank
      self.world_size: int = world_size
      self.sample_ratio: float = sample_ratio
      self.embedding_size: int = embedding_size
      self.fp16 = fp16
      self.num_local: int = (num_classes + world_size - 1) // world_size
      if num_classes % world_size != 0 and rank == world_size - 1:
          self.num_local = num_classes % self.num_local
      self.num_sample: int = int(self.sample_ratio * self.num_local)
      self.margin1 = margin1
      self.margin2 = margin2
      self.margin3 = margin3
      self.logit_scale = scale
  
      self._parameter_list = []
  
      if name is None:
          name = "dist@fc@rank@%05d.w" % rank
      assert ".w" in name
  
      stddev = math.sqrt(2.0 / (self.embedding_size + self.num_local))
      param_attr = paddle.ParamAttr(
          name=name,
          initializer=paddle.nn.initializer.Normal(std=stddev),
      )
  
      self.index = None
      self.weight = self.create_parameter(
          shape=[self.embedding_size, self.num_local],
          attr=param_attr,
          is_bias=False,
          dtype="float16" if self.fp16 else "float32",
      )
      self.weight.is_distributed = True
  
      if int(self.sample_ratio) < 1:
          self.weight.stop_gradient = True
  
file_path: insightface/recognition/arcface_paddle/dynamic/classifiers/lsc.py
imports: import warnings
  import math
  import os
  import paddle
  import paddle.nn
label_desc: Use image node_id 1 to create a new LargeScaleClassifier object from inherited base classes: nn with example: obj = LargeScaleClassifier(rank, world_size, num_classes, margin1, margin2, margin3, scale, sample_ratio, embedding_size, fp16, name)