def fgrad_y_psi(self, y, return_covar_chain=False):
mpsi = self.psi<EOL>w, s, r, d = self.fgrad_y(y, return_precalc=True)<EOL>gradients = np.zeros((y.shape[<NUM_LIT:0>], y.shape[<NUM_LIT:1>], len(mpsi), <NUM_LIT:4>))<EOL>for i in range(len(mpsi)):<EOL><INDENT>a,b,c  = mpsi[i]<EOL>gradients[:, :, i, <NUM_LIT:0>] = (b * (<NUM_LIT:1.0>/np.cosh(s[i])) ** <NUM_LIT:2>).T<EOL>gradients[:, :, i, <NUM_LIT:1>] = a * (d[i] - <NUM_LIT> * s[i] * r[i] * (<NUM_LIT:1.0>/np.cosh(s[i])) ** <NUM_LIT:2>).T<EOL>gradients[:, :, i, <NUM_LIT:2>] = (-<NUM_LIT> * a * (b ** <NUM_LIT:2>) * r[i] * ((<NUM_LIT:1.0> / np.cosh(s[i])) ** <NUM_LIT:2>)).T<EOL><DEDENT>gradients[:, :, <NUM_LIT:0>, <NUM_LIT:3>] = <NUM_LIT:1.0><EOL>if return_covar_chain:<EOL><INDENT>covar_grad_chain = np.zeros((y.shape[<NUM_LIT:0>], y.shape[<NUM_LIT:1>], len(mpsi), <NUM_LIT:4>))<EOL>for i in range(len(mpsi)):<EOL><INDENT>a,b,c = mpsi[i]<EOL>covar_grad_chain[:, :, i, <NUM_LIT:0>] = (r[i]).T<EOL>covar_grad_chain[:, :, i, <NUM_LIT:1>] = (a * (y + c) * ((<NUM_LIT:1.0> / np.cosh(s[i])) ** <NUM_LIT:2>).T)<EOL>covar_grad_chain[:, :, i, <NUM_LIT:2>] = a * b * ((<NUM_LIT:1.0> / np.cosh(s[i])) ** <NUM_LIT:2>).T<EOL><DEDENT>covar_grad_chain[:, :, <NUM_LIT:0>, <NUM_LIT:3>] = y<EOL>return gradients, covar_grad_chain<EOL><DEDENT>return gradients<EOL>
gradient of f w.r.t to y and psi

:returns: NxIx4 tensor of partial derivatives