code: def _process_deriv_args(f, kwargs):
      
      n = f.ndim
      axis = normalize_axis_index(kwargs.get('axis', 0), n)
  
      if f.shape[axis] < 3:
          raise ValueError('f must have at least 3 point along the desired axis.')
  
      if 'delta' in kwargs:
          if 'x' in kwargs:
              raise ValueError('Cannot specify both "x" and "delta".')
  
          delta = atleast_1d(kwargs['delta'])
          if delta.size == 1:
              diff_size = list(f.shape)
              diff_size[axis] -= 1
              delta_units = getattr(delta, 'units', None)
              delta = np.broadcast_to(delta, diff_size, subok=True)
              if delta_units is not None:
                  delta = delta * delta_units
          else:
              delta = _broadcast_to_axis(delta, axis, n)
      elif 'x' in kwargs:
          x = _broadcast_to_axis(kwargs['x'], axis, n)
          delta = diff(x, axis=axis)
      else:
          raise ValueError('Must specify either "x" or "delta" for value positions.')
  
      return n, axis, delta
docs: Handle common processing of arguments for derivative functions.