This method is overwritten because we need to modify kdiag by substituting z for x. We do this by calling the parent expression method to extract variables from expressions, then subsitute the z variables that are present with x.

def _set_expressions(self, expressions):
        """This method is overwritten because we need to modify kdiag by substituting z for x. We do this by calling the parent expression method to extract variables from expressions, then subsitute the z variables that are present with x."""
        Symbolic_core._set_expressions(self, expressions)
        Symbolic_core._set_variables(self, self.cacheable)
        # Substitute z with x to obtain kdiag.
        for x, z in zip(self.variables['X'], self.variables['Z']):
            expressions['kdiag'] = expressions['kdiag'].subs(z, x)
        Symbolic_core._set_expressions(self, expressions)