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 forward(self, feature, label):
      if self.world_size > 1:
          feature_list = []
          paddle.distributed.all_gather(feature_list, feature)
          total_feature = paddle.concat(feature_list, axis=0)
  
          label_list = []
          paddle.distributed.all_gather(label_list, label)
          total_label = paddle.concat(label_list, axis=0)
          total_label.stop_gradient = True
      else:
          total_feature = feature
          total_label = label
  
      if self.sample_ratio < 1.0:
          # partial fc sample process
          (
              total_label,
              self.index,
          ) = paddle.nn.functional.class_center_sample(
              total_label, self.num_local, self.num_sample
          )
          total_label.stop_gradient = True
          self.index.stop_gradient = True
          self.sub_weight = paddle.gather(
              self.weight, self.index, axis=1
          )
          self.sub_weight.stop_gradient = False
          self._parameter_list.append(self.sub_weight)
      else:
          self.sub_weight = self.weight
  
      norm_feature = paddle.fluid.layers.l2_normalize(
          total_feature, axis=1
      )
      norm_weight = paddle.fluid.layers.l2_normalize(
          self.sub_weight, axis=0
      )
  
      local_logit = paddle.matmul(norm_feature, norm_weight)
  
      loss = paddle.nn.functional.margin_cross_entropy(
          local_logit,
          total_label,
          margin1=self.margin1,
          margin2=self.margin2,
          margin3=self.margin3,
          scale=self.logit_scale,
          return_softmax=False,
          reduction=None,
      )
  
      loss = paddle.mean(loss)
  
      return loss
  
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 4 for calling the LargeScaleClassifier obj's underlying member method code with example usage: obj.forward(feature, label) and returns: loss