class_docstr: Selects instances by expected gradient length [Set07]_.
class_docstr_tok: ["Selects","instances","by","expected","gradient","length","[","Set07","]","_","."]
code: def compute_gradient_length(self, clf, sm, gradients, j, k):
      params = [
          param.grad.flatten()
          for param in clf.model.parameters()
          if param.requires_grad
      ]
      params = torch.cat(params)
  
      gradients[j, k] = torch.sqrt(params.pow(2)).sum()
      gradients[j, k] *= sm[k, j].item()
  
imports: import numpy
  from small_text.integrations.pytorch.exceptions import PytorchNotFoundError
  from small_text.query_strategies import constraints, QueryStrategy, EmbeddingBasedQueryStrategy
  from small_text.utils.clustering import init_kmeans_plusplus_safe
  from small_text.utils.context import build_pbar_context
  from small_text.utils.data import list_length
label_desc: Use image node_id 8 for calling the ExpectedGradientLength obj's underlying member method code with example usage: obj.compute_gradient_length(clf, sm, gradients, j, k) without return types