code: def valley(lrs: list, losses: list, num_it: int):
      "Suggests a learning rate from the longest valley and returns its index"
      n = len(losses)
      max_start, max_end = 0, 0
  
      # find the longest valley
      lds = [1] * n
      for i in range(1, n):
          for j in range(0, i):
              if (losses[i] < losses[j]) and (lds[i] < lds[j] + 1):
                  lds[i] = lds[j] + 1
              if lds[max_end] < lds[i]:
                  max_end = i
                  max_start = max_end - lds[max_end]
  
      sections = (max_end - max_start) / 3
      idx = max_start + int(sections) + int(sections / 2)
  
      return float(lrs[idx]), (float(lrs[idx]), losses[idx])
  
imports: from __future__ import annotations
  from ..basics import *
  from .tracker import SaveModelCallback
label_desc: Use image node_id 18 for calling a global function with example usage: valley(lrs, losses, num_it) and returns: float,  float,  losses