code: def keep_partial_grad(grad, topk):
      """
      Keep only the topk rows of grads.
      """
      assert topk < grad.size(0)
      grad.data[topk:].zero_()
      return grad
  
file_path: stanza/stanza/models/common/seq2seq_utils.py
imports: from collections import Counter
  import random
  import json
  import torch
  import stanza.models.common.seq2seq_constant
label_desc: Use image node_id 4 for calling a global function with example usage: keep_partial_grad(grad, topk) and returns: grad