add better gradient creation error message

Summary: Print the full operator definition when gradient creation fails. This helps debugging cases where same op type is used in many places.

Differential Revision: D6282832

fbshipit-source-id: 4b9dab2602c7c53f795da93a3085cf5c8ca741c1
diff --git a/caffe2/python/core.py b/caffe2/python/core.py
index 0246b23..2ba597b 100644
--- a/caffe2/python/core.py
+++ b/caffe2/python/core.py
@@ -1070,8 +1070,8 @@
                 )
             else:
                 raise Exception(
-                    "Exception when creating the gradient for [{}]: {}.".
-                    format(op.type, e)
+                    "Exception when creating gradient for [{}]:{}.\nOp: \n{}".
+                    format(op.type, e, str(op))
                 )
 
         if gradient_ops is None: