code: def update_lambda(self, *args, **kwargs):
          r
  
          if self.restart_strategy == 'greedy':
              return 2
  
          # Steps 3 and 4 from alg.10.7.
          self._t_prev = self._t_now
  
          if self.mode == 'regular':
              self._t_now = (self.p_lazy + np.sqrt(self.r_lazy *
                             self._t_prev ** 2 + self.q_lazy)) * 0.5
  
          elif self.mode == 'CD':
              self._t_now = (self._n + self.a_cd - 1) / self.a_cd
              self._n += 1
  
          return 1 + (self._t_prev - 1) / self._t_now
docs: r"""Update lambda
  
          This method updates the value of lambda
  
          Returns
          -------
          float current lambda value
  
          Notes
          -----
          Implements steps 3 and 4 from algoritm 10.7 in [B2011]_