class_docstr: autograd function which masks it's weights by 'mask'.
class_docstr_tok: ["autograd","function","which","masks","it","'s","weights","by","'mask","'","."]
code: def backward(ctx, grad_output):
      # pdb.set_trace()
      # print(float(grad_output))
      # This is a pattern that is very convenient - at the top of backward
      # unpack saved_tensors and initialize all gradients w.r.t. inputs to
      # None. Thanks to the fact that additional trailing Nones are
      # ignored, the return statement is simple even when the function has
      # optional inputs.
      input, weight, bias, mask = ctx.saved_tensors
      grad_input = grad_weight = grad_bias = grad_mask = None
  
      # These needs_input_grad checks are optional and there only to
      # improve efficiency. If you want to make your code simpler, you can
      # skip them. Returning gradients for inputs that don't require it is
      # not an error.
      if ctx.needs_input_grad[0]:
          grad_input = grad_output.mm(weight)
      if ctx.needs_input_grad[1]:
          grad_weight = grad_output.t().mm(input)
          if mask is not None:
              # change grad_weight to 0 where mask == 0
              grad_weight = grad_weight * mask
      # if bias is not None and ctx.needs_input_grad[2]:
      if ctx.needs_input_grad[2]:
          grad_bias = grad_output.sum(0).squeeze(0)
  
      # grad_bias = torch.Tensor([grad_bias])
  
      return grad_input, grad_weight, grad_bias, grad_mask
  
file_path: AIX360/aix360/algorithms/cofrnet/CustomizedLinearClasses.py
imports: import pandas
  import numpy
  import pandas
  import torch
  import torch.nn
  import torch.autograd
  from torch.autograd import Function
  from torch.nn.parameter import Parameter
  import torch.nn.functional
  import math
label_desc: Use image node_id 2 for calling the CustomizedLinearFunction obj's underlying member method code with example usage: obj.backward(ctx, grad_output) and returns: grad_input,  grad_weight,  grad_bias,  grad_mask