class_docstr: return a logistic regression problem
  
  There is a dataset consisting of features (vectors of norm <=1)
  and labels (+1,-1), represented as a numpy array.
  There is also an L2 regularizer.
docstr: Computes the gradient of the logistic regression at a given point w.
  
  If X,y is the data and reg is the regularizer, then the gradient is
  (-1/n)sum_i^n X[i,:]*y[i]/(1+exp(<w,X[i,:]*y[i]>)) + reg*w
code: def grad(self, param, batch_idx=None):
      """Computes the gradient of the logistic regression at a given point w.
  
      If X,y is the data and reg is the regularizer, then the gradient is
      (-1/n)sum_i^n X[i,:]*y[i]/(1+exp(<w,X[i,:]*y[i]>)) + reg*w
      """
      if batch_idx is not None:
          data_batch = self.data[batch_idx]
      else:
          data_batch = self.data
  
      coeff_grad = -1 / (1 + np.exp(np.dot(data_batch, param)))
      data_grad = np.mean(
          data_batch * coeff_grad[:, np.newaxis], axis=0
      )
      return data_grad + self.reg * param
  
file_path: privacy/research/dp_newton/src/my_logistic_regression.py
imports: import numpy
label_desc: Use image node_id 5 for calling the MyLogisticRegression obj's underlying member method code with example usage: obj.grad(param, batch_idx) and returns: unknown