code: def residual_unit_v2(
      data, num_filter, stride, dim_match, name, bottle_neck, **kwargs
  ):
      """Return ResNet Unit symbol for building ResNet
      Parameters
      ----------
      data : str
          Input data
      num_filter : int
          Number of output channels
      bnf : int
          Bottle neck channels factor with regard to num_filter
      stride : tuple
          Stride used in convolution
      dim_match : Boolean
          True means channel number between input and output is the same, otherwise means differ
      name : str
          Base name of the operators
      workspace : int
          Workspace used in convolution operator
      """
      use_se = kwargs.get("version_se", 1)
      bn_mom = kwargs.get("bn_mom", 0.9)
      workspace = kwargs.get("workspace", 256)
      memonger = kwargs.get("memonger", False)
      act_type = kwargs.get("version_act", "prelu")
      # print('in unit2')
      if bottle_neck:
          # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper
          bn1 = mx.sym.BatchNorm(
              data=data,
              fix_gamma=False,
              eps=2e-5,
              momentum=bn_mom,
              name=name + "_bn1",
          )
          act1 = Act(data=bn1, act_type=act_type, name=name + "_relu1")
          conv1 = Conv(
              data=act1,
              num_filter=int(num_filter * 0.25),
              kernel=(1, 1),
              stride=(1, 1),
              pad=(0, 0),
              no_bias=True,
              workspace=workspace,
              name=name + "_conv1",
          )
          bn2 = mx.sym.BatchNorm(
              data=conv1,
              fix_gamma=False,
              eps=2e-5,
              momentum=bn_mom,
              name=name + "_bn2",
          )
          act2 = Act(data=bn2, act_type=act_type, name=name + "_relu2")
          conv2 = Conv(
              data=act2,
              num_filter=int(num_filter * 0.25),
              kernel=(3, 3),
              stride=stride,
              pad=(1, 1),
              no_bias=True,
              workspace=workspace,
              name=name + "_conv2",
          )
          bn3 = mx.sym.BatchNorm(
              data=conv2,
              fix_gamma=False,
              eps=2e-5,
              momentum=bn_mom,
              name=name + "_bn3",
          )
          act3 = Act(data=bn3, act_type=act_type, name=name + "_relu3")
          conv3 = Conv(
              data=act3,
              num_filter=num_filter,
              kernel=(1, 1),
              stride=(1, 1),
              pad=(0, 0),
              no_bias=True,
              workspace=workspace,
              name=name + "_conv3",
          )
          if use_se:
              # se begin
              body = mx.sym.Pooling(
                  data=conv3,
                  global_pool=True,
                  kernel=(7, 7),
                  pool_type="avg",
                  name=name + "_se_pool1",
              )
              body = Conv(
                  data=body,
                  num_filter=num_filter // 16,
                  kernel=(1, 1),
                  stride=(1, 1),
                  pad=(0, 0),
                  name=name + "_se_conv1",
                  workspace=workspace,
              )
              body = Act(
                  data=body, act_type=act_type, name=name + "_se_relu1"
              )
              body = Conv(
                  data=body,
                  num_filter=num_filter,
                  kernel=(1, 1),
                  stride=(1, 1),
                  pad=(0, 0),
                  name=name + "_se_conv2",
                  workspace=workspace,
              )
              body = mx.symbol.Activation(
                  data=body,
                  act_type="sigmoid",
                  name=name + "_se_sigmoid",
              )
              conv3 = mx.symbol.broadcast_mul(conv3, body)
          if dim_match:
              shortcut = data
          else:
              shortcut = Conv(
                  data=act1,
                  num_filter=num_filter,
                  kernel=(1, 1),
                  stride=stride,
                  no_bias=True,
                  workspace=workspace,
                  name=name + "_sc",
              )
          if memonger:
              shortcut._set_attr(mirror_stage="True")
          return conv3 + shortcut
      else:
          bn1 = mx.sym.BatchNorm(
              data=data,
              fix_gamma=False,
              momentum=bn_mom,
              eps=2e-5,
              name=name + "_bn1",
          )
          act1 = Act(data=bn1, act_type=act_type, name=name + "_relu1")
          conv1 = Conv(
              data=act1,
              num_filter=num_filter,
              kernel=(3, 3),
              stride=stride,
              pad=(1, 1),
              no_bias=True,
              workspace=workspace,
              name=name + "_conv1",
          )
          bn2 = mx.sym.BatchNorm(
              data=conv1,
              fix_gamma=False,
              momentum=bn_mom,
              eps=2e-5,
              name=name + "_bn2",
          )
          act2 = Act(data=bn2, act_type=act_type, name=name + "_relu2")
          conv2 = Conv(
              data=act2,
              num_filter=num_filter,
              kernel=(3, 3),
              stride=(1, 1),
              pad=(1, 1),
              no_bias=True,
              workspace=workspace,
              name=name + "_conv2",
          )
          if use_se:
              # se begin
              body = mx.sym.Pooling(
                  data=conv2,
                  global_pool=True,
                  kernel=(7, 7),
                  pool_type="avg",
                  name=name + "_se_pool1",
              )
              body = Conv(
                  data=body,
                  num_filter=num_filter // 16,
                  kernel=(1, 1),
                  stride=(1, 1),
                  pad=(0, 0),
                  name=name + "_se_conv1",
                  workspace=workspace,
              )
              body = Act(
                  data=body, act_type=act_type, name=name + "_se_relu1"
              )
              body = Conv(
                  data=body,
                  num_filter=num_filter,
                  kernel=(1, 1),
                  stride=(1, 1),
                  pad=(0, 0),
                  name=name + "_se_conv2",
                  workspace=workspace,
              )
              body = mx.symbol.Activation(
                  data=body,
                  act_type="sigmoid",
                  name=name + "_se_sigmoid",
              )
              conv2 = mx.symbol.broadcast_mul(conv2, body)
          if dim_match:
              shortcut = data
          else:
              shortcut = Conv(
                  data=act1,
                  num_filter=num_filter,
                  kernel=(1, 1),
                  stride=stride,
                  no_bias=True,
                  workspace=workspace,
                  name=name + "_sc",
              )
          if memonger:
              shortcut._set_attr(mirror_stage="True")
          return conv2 + shortcut
  
file_path: insightface/recognition/partial_fc/mxnet/symbol/resnet.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  import os
  import mxnet
  import numpy
  from symbol import symbol_utils
  from default import config
label_desc: Use image node_id 5 for calling a global function with example usage: residual_unit_v2(data, num_filter, stride, dim_match, name, bottle_neck) and returns: unknown, unknown