class_docstr: Cosine layer defined in
  "Learning a Unified Classifier Incrementally via Rebalancing"
  by Saihui Hou et al.
  
  Implementation modified from https://github.com/G-U-N/PyCIL
  
  This layer is aimed at countering the task-recency bias by removing the bias
  in the classifier and normalizing the weight and the input feature before
  computing the weight-feature product
class_docstr_tok: ["Cosine","layer","defined","in","''","Learning","a","Unified","Classifier","Incrementally","via","Rebalancing","''","by","Saihui","Hou","et","al",".","Implementation","modified","from","https",":","\/\/github.com\/G-U-N\/PyCIL","This","layer","is","aimed","at","countering","the","task-recency","bias","by","removing","the","bias","in","the","classifier","and","normalizing","the","weight","and","the","input","feature","before","computing","the","weight-feature","product"]
docstr: :param in_features: number of input features
  :param out_features: number of classes
  :param sigma: learnable output scaling factor
docstr_tok: [":","param","in_features",":","number","of","input","features",":","param","out_features",":","number","of","classes",":","param","sigma",":","learnable","output","scaling","factor"]
code: def __init__(self, in_features, out_features, sigma=True):
      """
      :param in_features: number of input features
      :param out_features: number of classes
      :param sigma: learnable output scaling factor
      """
      super().__init__()
      self.in_features = in_features
      self.out_features = out_features
      self.weight = nn.Parameter(
          torch.Tensor(self.out_features, in_features)
      )
      if sigma:
          self.sigma = nn.Parameter(torch.Tensor(1))
      else:
          self.register_parameter("sigma", None)
      self.reset_parameters()
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  import numpy
  from avalanche.models import DynamicModule
label_desc: Use image node_id 1 to create a new CosineLinear object from inherited base classes: nn with example: obj = CosineLinear(in_features, out_features, sigma)