class_docstr: A Pytorch implementation of ADMM Pruner algorithm.
  
  Parameters
  ----------
  model : torch.nn.Module
      Model to be pruned.
  config_list : list
      List on pruning configs.
  trainer : function
      Function used for the first subproblem.
      Users should write this function as a normal function to train the Pytorch model
      and include `model, optimizer, criterion, epoch, callback` as function arguments.
      Here `callback` acts as an L2 regulizer as presented in the formula (7) of the original paper.
      The logic of `callback` is implemented inside the Pruner,
      users are just required to insert `callback()` between `loss.backward()` and `optimizer.step()`.
      Example::
  
          def trainer(model, criterion, optimizer, epoch, callback):
              device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
              train_loader = ...
              model.train()
              for batch_idx, (data, target) in enumerate(train_loader):
                  data, target = data.to(device), target.to(device)
                  optimizer.zero_grad()
                  output = model(data)
                  loss = criterion(output, target)
                  loss.backward()
                  # callback should be inserted between loss.backward() and optimizer.step()
                  if callback:
                      callback()
                  optimizer.step()
  num_iterations : int
      Total number of iterations.
  training_epochs : int
      Training epochs of the first subproblem.
  row : float
      Penalty parameters for ADMM training.
  base_algo : str
      Base pruning algorithm. `level`, `l1`, `l2` or `fpgm`, by default `l1`. Given the sparsity distribution among the ops,
      the assigned `base_algo` is used to decide which filters/channels/weights to prune.
class_docstr_tok: ["A","Pytorch","implementation","of","ADMM","Pruner","algorithm",".","Parameters","--","--","--","--","--","model",":","torch.nn.Module","Model","to","be","pruned",".","config_list",":","list","List","on","pruning","configs",".","trainer",":","function","Function","used","for","the","first","subproblem",".","Users","should","write","this","function","as","a","normal","function","to","train","the","Pytorch","model","and","include","`","model",",","optimizer",",","criterion",",","epoch",",","callback","`","as","function","arguments",".","Here","`","callback","`","acts","as","an","L2","regulizer","as","presented","in","the","formula","(","7",")","of","the","original","paper",".","The","logic","of","`","callback","`","is","implemented","inside","the","Pruner",",","users","are","just","required","to","insert","`","callback","(",")","`","between","`","loss.backward","(",")","`","and","`","optimizer.step","(",")","`",".","Example",":",":","def","trainer","(","model",",","criterion",",","optimizer",",","epoch",",","callback",")",":","device","=","torch.device","(","``","cuda","''","if","torch.cuda.is_available","(",")","else","``","cpu","''",")","train_loader","=","...","model.train","(",")","for","batch_idx",",","(","data",",","target",")","in","enumerate","(","train_loader",")",":","data",",","target","=","data.to","(","device",")",",","target.to","(","device",")","optimizer.zero_grad","(",")","output","=","model","(","data",")","loss","=","criterion","(","output",",","target",")","loss.backward","(",")","#","callback","should","be","inserted","between","loss.backward","(",")","and","optimizer.step","(",")","if","callback",":","callback","(",")","optimizer.step","(",")","num_iterations",":","int","Total","number","of","iterations",".","training_epochs",":","int","Training","epochs","of","the","first","subproblem",".","row",":","float","Penalty","parameters","for","ADMM","training",".","base_algo",":","str","Base","pruning","algorithm",".","`","level","`",",","`","l1","`",",","`","l2","`","or","`","fpgm","`",",","by","default","`","l1","`",".","Given","the","sparsity","distribution","among","the","ops",",","the","assigned","`","base_algo","`","is","used","to","decide","which","filters\/channels\/weights","to","prune","."]
docstr: Return the Euclidean projection of the weight matrix according to the pruning mode.
  
  Parameters
  ----------
  weight : tensor
      original matrix
  sparsity : float
      the ratio of parameters which need to be set to zero
  wrapper: PrunerModuleWrapper
      layer wrapper of this layer
  
  Returns
  -------
  tensor
      the projected matrix
docstr_tok: ["Return","the","Euclidean","projection","of","the","weight","matrix","according","to","the","pruning","mode",".","Parameters","--","--","--","--","--","weight",":","tensor","original","matrix","sparsity",":","float","the","ratio","of","parameters","which","need","to","be","set","to","zero","wrapper",":","PrunerModuleWrapper","layer","wrapper","of","this","layer","Returns","--","--","--","-","tensor","the","projected","matrix"]
code: def _projection(self, weight, sparsity, wrapper):
      """
      Return the Euclidean projection of the weight matrix according to the pruning mode.
  
      Parameters
      ----------
      weight : tensor
          original matrix
      sparsity : float
          the ratio of parameters which need to be set to zero
      wrapper: PrunerModuleWrapper
          layer wrapper of this layer
  
      Returns
      -------
      tensor
          the projected matrix
      """
      wrapper_copy = copy.deepcopy(wrapper)
      wrapper_copy.module.weight.data = weight
      return weight.data.mul(
          self.masker.calc_mask(sparsity, wrapper_copy)["weight_mask"]
      )
  
file_path: auptimizer/src/aup/compression/torch/pruning/admm_pruner.py
imports: import logging
  import torch
  from schema import And, Optional
  import copy
  from ..utils.config_validation import CompressorSchema
  from .constants import MASKER_DICT
  from .one_shot import OneshotPruner
label_desc: Use image node_id 3 for calling the ADMMPruner obj's underlying member method code with example usage: obj._projection(weight, sparsity, wrapper) and returns: weight