def dparam_checkgrad(func, dfunc, params, params_names, args, constraints=None, randomize=False, verbose=False):
print("<STR_LIT>".format(func.__self__.__class__.__name__,<EOL>func.__name__, dfunc.__name__))<EOL>partial_f = dparam_partial(func, *args)<EOL>partial_df = dparam_partial(dfunc, *args)<EOL>gradchecking = True<EOL>zipped_params = zip(params, params_names)<EOL>for param_ind, (param_val, param_name) in enumerate(zipped_params):<EOL><INDENT>f_ = partial_f(param_val, param_name)<EOL>df_ = partial_df(param_val, param_name)<EOL>f_ = f_.reshape(-<NUM_LIT:1>, f_.shape[<NUM_LIT:0>], f_.shape[<NUM_LIT:1>])<EOL>df_ = df_.reshape(-<NUM_LIT:1>, f_.shape[<NUM_LIT:0>], f_.shape[<NUM_LIT:1>])<EOL>fnum = f_.shape[-<NUM_LIT:2>]<EOL>fdim = f_.shape[-<NUM_LIT:1>]<EOL>dfnum = df_.shape[-<NUM_LIT:2>]<EOL>for fixed_val in range(dfnum):<EOL><INDENT>f_ind = min(fnum, fixed_val+<NUM_LIT:1>) - <NUM_LIT:1><EOL>print("<STR_LIT>".format(fnum, dfnum, f_ind, fixed_val))<EOL>func = lambda p_val: partial_f(p_val, param_name).reshape(-<NUM_LIT:1>, fnum, fdim)[param_ind, f_ind, :]<EOL>dfunc_dparam = lambda d_val: partial_df(d_val, param_name).reshape(-<NUM_LIT:1>, fnum, fdim)[param_ind, fixed_val, :]<EOL>grad = GradientChecker(func, dfunc_dparam, param_val, [param_name])<EOL>if constraints is not None:<EOL><INDENT>for constrain_param, constraint in constraints:<EOL><INDENT>if grad.grep_param_names(constrain_param):<EOL><INDENT>constraint(constrain_param, grad)<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>print(constrain_param, "<STR_LIT:U+0020>", constraint)<EOL><DEDENT><DEDENT>if randomize:<EOL><INDENT>grad.randomize()<EOL><DEDENT>if verbose:<EOL><INDENT>print(grad)<EOL>grad.checkgrad(verbose=<NUM_LIT:1>)<EOL><DEDENT>if not grad.checkgrad(verbose=True):<EOL><INDENT>gradchecking = False<EOL><DEDENT>if not grad.checkgrad(verbose=True):<EOL><INDENT>gradchecking = False<EOL><DEDENT><DEDENT><DEDENT>return gradchecking<EOL>
checkgrad expects a f: R^N -> R^1 and df: R^N -> R^N
However if we are holding other parameters fixed and moving something else
We need to check the gradient of each of the fixed parameters
(f and y for example) seperately,  whilst moving another parameter.
Otherwise f: gives back R^N and
          df: gives back R^NxM where M is
The number of parameters and N is the number of data
Need to take a slice out from f and a slice out of df