code: def grad_and_loss(func, argnum=None):
      """Return function that computes both gradient of arguments and loss value.
  
      Parameters
      ----------
      func: a python function
          The forward (loss) function.
      argnum: an int or a list of int
          The index of argument to calculate gradient for.
  
      Returns
      -------
      grad_and_loss_func: a python function
          A function that would compute both the gradient of arguments and loss value.
      """
  
      @functools.wraps(func)
      def wrapped(*args):
          """Wrapped function."""
          variables = args
          if argnum is not None:
              argnum_ = argnum if isinstance(argnum, list) else [argnum]
              variables = [args[i] for i in argnum_]
          for x in variables:
              assert isinstance(
                  x, NDArray
              ), "type of autograd input should NDArray."
          grads = [zeros_like(x) for x in variables]
          mark_variables(variables, grads)
          with record():
              outputs = func(*args)
          backward(
              [outputs] if isinstance(outputs, NDArray) else outputs
          )
          return grads, outputs
  
      return wrapped
  
imports: import functools
  import mxnet.ndarray
  from mxnet.ndarray import zeros_like
  from mxnet.autograd import *
  from mxnet.test_utils import *
  from common import xfail_when_nonstandard_decimal_separator
  from mxnet.test_utils import environment
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: grad_and_loss(func, argnum) and returns: wrapped, grads,  outputs