@docfiller<EOL>def generic_gradient_magnitude(input, derivative, output=None,<EOL>mode="<STR_LIT>", cval=<NUM_LIT:0.0>,<EOL>extra_arguments=(), extra_keywords = None):
if extra_keywords is None:<EOL><INDENT>extra_keywords = {}<EOL><DEDENT>input = numpy.asarray(input)<EOL>output, return_value = _ni_support._get_output(output, input)<EOL>axes = list(range(input.ndim))<EOL>if len(axes) > <NUM_LIT:0>:<EOL><INDENT>derivative(input, axes[<NUM_LIT:0>], output, mode, cval,<EOL>*extra_arguments, **extra_keywords)<EOL>numpy.multiply(output, output, output)<EOL>for ii in range(<NUM_LIT:1>, len(axes)):<EOL><INDENT>tmp = derivative(input, axes[ii], output.dtype, mode, cval,<EOL>*extra_arguments, **extra_keywords)<EOL>numpy.multiply(tmp, tmp, tmp)<EOL>output += tmp<EOL><DEDENT>if NumpyVersion(numpy.__version__) > '<STR_LIT>':<EOL><INDENT>numpy.sqrt(output, output, casting='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>numpy.sqrt(output, output)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>output[...] = input[...]<EOL><DEDENT>return return_value<EOL>
Gradient magnitude using a provided gradient function.

    Parameters
    ----------
    %(input)s
    derivative : callable
        Callable with the following signature::

            derivative(input, axis, output, mode, cval,
                       *extra_arguments, **extra_keywords)

        See `extra_arguments`, `extra_keywords` below.
        `derivative` can assume that `input` and `output` are ndarrays.
        Note that the output from `derivative` is modified inplace;
        be careful to copy important inputs before returning them.
    %(output)s
    %(mode)s
    %(cval)s
    %(extra_keywords)s
    %(extra_arguments)s