code: def backtracking_ls(lrp, dir_srch, w_start, alpha=0.4, beta=0.95):
      """Implementation of backtracking line search
  
      lr = logistic regression
      dir = the "noisy" gradient direction
      w_start = current point
      alpha and beta tradeoff the precision and complexity of the linesearch
  
      output is an (close to) optimal stepsize
      """
      step_size = 100
      val_0 = lrp.loss(w_start)
      inner_prod = np.dot(dir_srch, lrp.grad(w_start))
      while (
          lrp.loss(w_start - step_size * dir_srch)
          >= val_0 - step_size * alpha * inner_prod
      ):
          step_size = beta * step_size
          if step_size < 1e-6:
              break
      return step_size
  
imports: import time
  from my_logistic_regression import MyLogisticRegression
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: backtracking_ls(lrp, dir_srch, w_start, alpha, beta) and returns: step_size