class_docstr: Interprets the prediction using SmoothGrad (https://arxiv.org/abs/1706.03825)
  
  Registered as a `SaliencyInterpreter` with name "smooth-gradient".
class_docstr_tok: ["Interprets","the","prediction","using","SmoothGrad","(","https",":","\/\/arxiv.org\/abs\/1706.03825",")","Registered","as","a","`","SaliencyInterpreter","`","with","name","``","smooth-gradient","''","."]
docstr: Register a forward hook on the embedding layer which adds random noise to every embedding.
  Used for one term in the SmoothGrad sum.
docstr_tok: ["Register","a","forward","hook","on","the","embedding","layer","which","adds","random","noise","to","every","embedding",".","Used","for","one","term","in","the","SmoothGrad","sum","."]
code: def _register_forward_hook(self, stdev: float):
      """
      Register a forward hook on the embedding layer which adds random noise to every embedding.
      Used for one term in the SmoothGrad sum.
      """
  
      def forward_hook(module, inputs, output):
          # Random noise = N(0, stdev * (max-min))
          scale = output.detach().max() - output.detach().min()
          noise = (
              torch.randn(output.shape, device=output.device)
              * stdev
              * scale
          )
  
          # Add the random noise
          output.add_(noise)
  
      # Register the hook
      embedding_layer = self.predictor.get_interpretable_layer()
      handle = embedding_layer.register_forward_hook(forward_hook)
      return handle
  
file_path: allennlp/allennlp/interpret/saliency_interpreters/smooth_gradient.py
imports: import math
  from typing import Dict, Any
  import numpy
  import torch
  from allennlp.common.util import JsonDict, sanitize
  from allennlp.data import Instance
  from allennlp.interpret.saliency_interpreters.saliency_interpreter import SaliencyInterpreter
  from allennlp.predictors import Predictor
label_desc: Use image node_id 3 for calling the SmoothGradient obj's underlying member method code with example usage: obj._register_forward_hook(stdev) and returns: handle