code: def gradient(self):
          
  
          # First we store the functional in a variable
          functional = self
  
          # The class corresponding to the gradient operator.
          class MyGradientOperator(odl.Operator):
  
              """Class implementing the gradient operator."""
  
              def __init__(self):
                  """Initialize a new instance."""
                  super(MyGradientOperator, self).__init__(
                      domain=functional.domain, range=functional.domain)
  
              def _call(self, x):
                  """Evaluate the gradient."""
                  # Here we can access the store functional from a few lines
                  # above
                  return 2.0 * x + functional.y
  
          return MyGradientOperator()
docs: The gradient operator.