def expr(self, model, data, ** kwargs):
        """
        Returns a theano expression for the cost function.

        Returns a symbolic expression for a cost function applied to the
        minibatch of data.
        Optionally, may return None. This represents that the cost function
        is intractable but may be optimized via the get_gradients method.

        Parameters
        ----------
        model : a pylearn2 Model instance
        data : a batch in cost.get_data_specs() form
        kwargs : dict
            Optional extra arguments. Not used by the base class.
        """

        # Fall back to cost_per_example implementation if possible
        try:
            per_example = self.cost_per_example(self, model, data, **kwargs)
        except __HOLE__:
            raise NotImplementedError(str(type(self)) + " does not implement "
                                      "expr.")

        # Handle explicitly undefined costs
        if per_example is None:
            return None

        assert per_example.ndim == 1

        return per_example.mean()
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/costs/cost.py/Cost.expr