code: def gradient(self):
          
          functional = self
  
          class KLCrossEntropyGradient(Operator):
  
              """The gradient operator of this functional."""
  
              def __init__(self):
                  """Initialize a new instance."""
                  super(KLCrossEntropyGradient, self).__init__(
                      functional.domain, functional.domain, linear=False)
  
              def _call(self, x):
                  """Apply the gradient operator to the given point.
  
                  The gradient is not defined in for points with components less
                  than or equal to zero.
                  """
                  if functional.prior is None:
                      tmp = np.log(x)
                  else:
                      tmp = np.log(x / functional.prior)
  
                  if np.all(np.isfinite(tmp)):
                      return tmp
                  else:
                      # The derivative is not defined.
                      raise ValueError('The gradient of the Kullback-Leibler '
                                       'Cross Entropy functional is not defined '
                                       'for `x` with one or more components '
                                       'less than or equal to zero.'.format(x))
  
          return KLCrossEntropyGradient()
docs: Gradient operator of the functional.
  
          The gradient is not defined in points where one or more components
          are less than or equal to 0.