code: def linear_param_grads(
      module: Module,
      activation: Tensor,
      gradient_out: Tensor,
      reset: bool = False,
  ) -> None:
      r"""
      Computes parameter gradients per sample for nn.Linear module, given module
      input activations and output gradients.
  
      Gradients are accumulated in the sample_grad attribute of each parameter
      (weight and bias). If reset = True, any current sample_grad values are reset,
      otherwise computed gradients are accumulated and added to the existing
      stored gradients.
  
      Inputs with more than 2 dimensions are only supported with torch 1.8 or later
      """
      if reset:
          _reset_sample_grads(module)
  
      module.weight.sample_grad += torch.einsum(  # type: ignore
          "n...i,n...j->nij", gradient_out, activation
      )
      if module.bias is not None:
          module.bias.sample_grad += torch.einsum(  # type: ignore
              "n...i->ni", gradient_out
          )
  
imports: from collections import defaultdict
  from enum import Enum
  from typing import cast, DefaultDict, Iterable, List, Optional, Tuple, Union
  import torch
  from captum._utils.common import _format_tensor_into_tuples, _register_backward_hook
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 2 for calling a global function with example usage: linear_param_grads(module, activation, gradient_out, reset) without return types