code: def _extgrad(xarr, alpha=100, axis=None):
      '''Given an array xarr of values, return the gradient of the smooth min/max
      swith respect to each entry in the array'''
      term1 = (np.exp(alpha*xarr)/
                  np.sum(np.exp(alpha*xarr), axis=axis, keepdims=True))
      term2 = 1 + alpha*(xarr - _extalg(xarr, alpha, axis=axis))
  
      return term1*termf _extgrad(xarr, alpha=100, axis=None):
      '''Given an array xarr of values, return the gradient of the smooth min/max
      swith respect to each entry in the array'''
      term1 = (np.exp(alpha*xarr)/
                  np.sum(np.exp(alpha*xarr), axis=axis, keepdims=True))
      term2 = 1 + alpha*(xarr - _extalg(xarr, alpha, axis=axis))
  
      return term1*term2
docs: Given an array xarr of values, return the gradient of the smooth min/max
      swith respect to each entry in the array