class_docstr: NaiveGroupNorm implements Group Normalization with the high-level matrix operations in PyTorch.
  It is a temporary solution to export GN by ONNX before the official GN can be exported by ONNX.
  The usage of NaiveGroupNorm is exactly the same as the official :class:`torch.nn.GroupNorm`.
  Args:
      num_groups (int): number of groups to separate the channels into
      num_channels (int): number of channels expected in input
      eps: a value added to the denominator for numerical stability. Default: 1e-5
      affine: a boolean value that when set to ``True``, this module
          has learnable per-channel affine parameters initialized to ones (for weights)
          and zeros (for biases). Default: ``True``.
  
  Shape:
      - Input: :math:`(N, C, *)` where :math:`C=\text{num\_channels}`
      - Output: :math:`(N, C, *)` (same shape as input)
  
  Examples::
  
      >>> input = torch.randn(20, 6, 10, 10)
      >>> # Separate 6 channels into 3 groups
      >>> m = NaiveGroupNorm(3, 6)
      >>> # Separate 6 channels into 6 groups (equivalent with InstanceNorm)
      >>> m = NaiveGroupNorm(6, 6)
      >>> # Put all 6 channels into a single group (equivalent with LayerNorm)
      >>> m = NaiveGroupNorm(1, 6)
      >>> # Activating the module
      >>> output = m(input)
  
  .. _`Group Normalization`: https://arxiv.org/abs/1803.08494
class_docstr_tok: ["NaiveGroupNorm","implements","Group","Normalization","with","the","high-level","matrix","operations","in","PyTorch",".","It","is","a","temporary","solution","to","export","GN","by","ONNX","before","the","official","GN","can","be","exported","by","ONNX",".","The","usage","of","NaiveGroupNorm","is","exactly","the","same","as","the","official",":","class",":","`","torch.nn.GroupNorm","`",".","Args",":","num_groups","(","int",")",":","number","of","groups","to","separate","the","channels","into","num_channels","(","int",")",":","number","of","channels","expected","in","input","eps",":","a","value","added","to","the","denominator","for","numerical","stability",".","Default",":","1e-5","affine",":","a","boolean","value","that","when","set","to","``","True","``",",","this","module","has","learnable","per-channel","affine","parameters","initialized","to","ones","(","for","weights",")","and","zeros","(","for","biases",")",".","Default",":","``","True","``",".","Shape",":","-","Input",":",":","math",":","`","(","N",",","C",",","*",")","`","where",":","math",":","`","C=\\text","{","num\\_channels","}","`","-","Output",":",":","math",":","`","(","N",",","C",",","*",")","`","(","same","shape","as","input",")","Examples",":",":",">",">",">","input","=","torch.randn","(","20",",","6",",","10",",","10",")",">",">",">","#","Separate","6","channels","into","3","groups",">",">",">","m","=","NaiveGroupNorm","(","3",",","6",")",">",">",">","#","Separate","6","channels","into","6","groups","(","equivalent","with","InstanceNorm",")",">",">",">","m","=","NaiveGroupNorm","(","6",",","6",")",">",">",">","#","Put","all","6","channels","into","a","single","group","(","equivalent","with","LayerNorm",")",">",">",">","m","=","NaiveGroupNorm","(","1",",","6",")",">",">",">","#","Activating","the","module",">",">",">","output","=","m","(","input",")","..","_","`","Group","Normalization","`",":","https",":","\/\/arxiv.org\/abs\/1803.08494"]
code: def forward(self, input):
      N, C, H, W = input.size()
      assert C % self.num_groups == 0
      input = input.reshape(N, self.num_groups, -1)
      mean = input.mean(dim=-1, keepdim=True)
      var = (input**2).mean(dim=-1, keepdim=True) - mean**2
      std = torch.sqrt(var + self.eps)
  
      input = (input - mean) / std
      input = input.reshape(N, C, H, W)
      if self.affine:
          input = input * self.weight.reshape(
              1, C, 1, 1
          ) + self.bias.reshape(1, C, 1, 1)
      return input
  
file_path: gluon-cv/gluoncv/torch/nn/group_norm.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn import Module, Parameter
  from torch.nn import init
label_desc: Use image node_id 3 for calling the NaiveGroupNorm obj's underlying member method code with example usage: obj.forward(input) and returns: input