code: def __init__(
      self,
      model,
      input_record,
      output_dims,
      weight_init=None,
      bias_init=None,
      weight_optim=None,
      bias_optim=None,
      name="fc",
      weight_reg=None,
      bias_reg=None,
      clip_param=None,
      max_fc_size=None,
      axis=1,
      transposed=False,
      uniform_weight_init_scale_numerator=1.0,
      **kwargs,
  ):
      super().__init__(model, name, input_record, **kwargs)
      assert isinstance(
          input_record, schema.Scalar
      ), "Incorrect input type {}".format(input_record)
      assert (
          len(input_record.field_types()[0].shape) > 0
      ), "FC expects limited dimensions of the input tensor"
      assert axis >= 1, "axis {} should >= 1.".format(axis)
      self.axis = axis
      input_dims = np.prod(
          input_record.field_types()[0].shape[axis - 1 :]
      )
  
      assert (
          input_dims > 0
      ), "FC expects input dimensions > 0, got {}".format(input_dims)
  
      self.clip_args = None
      if clip_param is not None:
          assert len(clip_param) == 2, (
              "clip_param must be a tuple / list "
              "of length 2 and in the form of (clip_min, clip max)"
          )
          clip_min, clip_max = clip_param
          assert (
              clip_min is not None or clip_max is not None
          ), "clip_min, and clip_max in clip_param cannot both be None"
          assert (
              clip_min is None or clip_max is None
          ) or clip_min < clip_max, "clip_param = [clip_min, clip_max] must have clip_min < clip_max"
          self.clip_args = {}
          if clip_min is not None:
              self.clip_args["min"] = clip_min
          if clip_max is not None:
              self.clip_args["max"] = clip_max
  
      if uniform_weight_init_scale_numerator is None:
          uniform_weight_init_scale_numerator = 1.0
  
      scale = math.sqrt(
          uniform_weight_init_scale_numerator / input_dims
      )
      weight_init = (
          weight_init
          if weight_init
          else ("UniformFill", {"min": -scale, "max": scale})
      )
      bias_init = (
          bias_init
          if bias_init
          else ("UniformFill", {"min": -scale, "max": scale})
      )
  
      self.output_dim_vec = FC.calculate_fc_output_dims(
          max_fc_size, input_dims, output_dims
      )
  
      self.transposed = transposed
      if self.output_dim_vec is None or len(self.output_dim_vec) == 1:
          weight_shape = (
              [input_dims, output_dims]
              if transposed
              else [output_dims, input_dims]
          )
          self.w = self.create_param(
              param_name="w",
              shape=weight_shape,
              initializer=weight_init,
              optimizer=weight_optim,
              regularizer=weight_reg,
          )
  
          self.b = self.create_param(
              param_name="b",
              shape=[
                  output_dims,
              ],
              initializer=bias_init,
              optimizer=bias_optim,
              regularizer=bias_reg,
          )
      else:
          self.w_vec = []
          self.b_vec = []
  
          for idx, output_dim in enumerate(self.output_dim_vec):
              weight_shape = (
                  [input_dims, output_dim]
                  if transposed
                  else [output_dim, input_dims]
              )
              self.w_vec.append(
                  self.create_param(
                      param_name="w_sub_{}".format(idx),
                      shape=weight_shape,
                      initializer=weight_init,
                      optimizer=weight_optim,
                      regularizer=weight_reg,
                  )
              )
  
              self.b_vec.append(
                  self.create_param(
                      param_name="b_sub_{}".format(idx),
                      shape=[
                          output_dim,
                      ],
                      initializer=weight_init,
                      optimizer=weight_optim,
                      regularizer=weight_reg,
                  )
              )
      if axis == 1:
          output_shape = (output_dims,)
      else:
          output_shape = list(input_record.field_types()[0].shape)[
              0 : axis - 1
          ]
          output_shape = tuple(output_shape + [output_dims])
  
      self.output_schema = schema.Scalar(
          (np.float32, output_shape),
          self.get_next_blob_reference("output"),
      )
  
file_path: pytorch/caffe2/python/layers/fc.py
imports: from caffe2.python.helpers.arg_scope import get_current_scope
  from caffe2.python import schema
  from caffe2.python.layers.layers import ModelLayer
  from caffe2.python.layers.sampling_trainable_mixin import SamplingTrainableMixin
  import math
  import numpy
label_desc: Use image node_id 1 to create a new FC object from inherited base classes: SamplingTrainableMixin, ModelLayer with example: obj = FC(model, input_record, output_dims, weight_init, bias_init, weight_optim, bias_optim, name, weight_reg, bias_reg, clip_param, max_fc_size, axis, transposed, uniform_weight_init_scale_numerator)