code: def _gen_subgradient_pass(subnet, init_grad):
      from caffe2.python.core import IR
  
      subnet_ir = IR(subnet.op)
      grad_ops, grad_blob_map = subnet_ir.GetBackwardPass(init_grad)
      grad_names_map = {}
      for b, g in grad_blob_map.items():
          grad_names_map[str(b)] = str(g)
      return grad_ops, grad_names_map
  
file_path: pytorch/caffe2/python/control_ops_grad.py
imports: from caffe2.proto import caffe2_pb2
label_desc: Use image node_id 10 for calling a global function with example usage: _gen_subgradient_pass(subnet, init_grad) and returns: grad_ops,  grad_names_map