def __init__(self, op_tree, be, next_error=None):
        # check type
        assert (type(op_tree) in _scalar_types or type(op_tree) == OpTreeNode or
                isinstance(op_tree, Tensor)), "op_tree type not supported"
        assert be is not None

        # attributes
        self.op_tree = op_tree
        self.be = be
        self.dtype = be.default_dtype
        if next_error is not None:
            assert next_error.shape == op_tree.shape, (
                "next_error.shape %s must be consistant with op_tree.shape %s"
                % (next_error.shape, op_tree.shape))
            self.next_error = next_error
        else:
            self.next_error = self.be.ones(op_tree.shape)

        self.map_tensor_grad_node = {}  # for building grad tree
        self.map_tensor_grad_op_tree = {}  # quick access to grad_op_tree

        # build_grad
        self.grad_node = GradNode(op_tree, self)
        if self.next_error:
            self.grad_node.grad_op_tree = self.next_error
        else:
            self.grad_node.grad_op_tree = self.be.ones(self.op_tree.shape)
        self.grad_node.build_grad()
dataset/ETHPy150Open NervanaSystems/neon/neon/backends/autodiff.py/Autodiff.__init__/original