code: def get_learned_conditioning_prompt_schedules(
      prompts, base_steps, hires_steps=None, use_old_scheduling=False
  ):
      """
      >>> g = lambda p: get_learned_conditioning_prompt_schedules([p], 10)[0]
      >>> g("test")
      [[10, 'test']]
      >>> g("a [b:3]")
      [[3, 'a '], [10, 'a b']]
      >>> g("a [b: 3]")
      [[3, 'a '], [10, 'a b']]
      >>> g("a [[[b]]:2]")
      [[2, 'a '], [10, 'a [[b]]']]
      >>> g("[(a:2):3]")
      [[3, ''], [10, '(a:2)']]
      >>> g("a [b : c : 1] d")
      [[1, 'a b  d'], [10, 'a  c  d']]
      >>> g("a[b:[c:d:2]:1]e")
      [[1, 'abe'], [2, 'ace'], [10, 'ade']]
      >>> g("a [unbalanced")
      [[10, 'a [unbalanced']]
      >>> g("a [b:.5] c")
      [[5, 'a  c'], [10, 'a b c']]
      >>> g("a [{b|d{:.5] c")  # not handling this right now
      [[5, 'a  c'], [10, 'a {b|d{ c']]
      >>> g("((a][:b:c [d:3]")
      [[3, '((a][:b:c '], [10, '((a][:b:c d']]
      >>> g("[a|(b:1.1)]")
      [[1, 'a'], [2, '(b:1.1)'], [3, 'a'], [4, '(b:1.1)'], [5, 'a'], [6, '(b:1.1)'], [7, 'a'], [8, '(b:1.1)'], [9, 'a'], [10, '(b:1.1)']]
      >>> g("[fe|]male")
      [[1, 'female'], [2, 'male'], [3, 'female'], [4, 'male'], [5, 'female'], [6, 'male'], [7, 'female'], [8, 'male'], [9, 'female'], [10, 'male']]
      >>> g("[fe|||]male")
      [[1, 'female'], [2, 'male'], [3, 'male'], [4, 'male'], [5, 'female'], [6, 'male'], [7, 'male'], [8, 'male'], [9, 'female'], [10, 'male']]
      >>> g = lambda p: get_learned_conditioning_prompt_schedules([p], 10, 10)[0]
      >>> g("a [b:.5] c")
      [[10, 'a b c']]
      >>> g("a [b:1.5] c")
      [[5, 'a  c'], [10, 'a b c']]
      """
  
      if hires_steps is None or use_old_scheduling:
          int_offset = 0
          flt_offset = 0
          steps = base_steps
      else:
          int_offset = base_steps
          flt_offset = 1.0
          steps = hires_steps
  
      def collect_steps(steps, tree):
          res = [steps]
  
          class CollectSteps(lark.Visitor):
              def scheduled(self, tree):
                  s = tree.children[-2]
                  v = float(s)
                  if use_old_scheduling:
                      v = v * steps if v < 1 else v
                  else:
                      if "." in s:
                          v = (v - flt_offset) * steps
                      else:
                          v = v - int_offset
                  tree.children[-2] = min(steps, int(v))
                  if tree.children[-2] >= 1:
                      res.append(tree.children[-2])
  
              def alternate(self, tree):
                  res.extend(range(1, steps + 1))
  
          CollectSteps().visit(tree)
          return sorted(set(res))
  
      def at_step(step, tree):
          class AtStep(lark.Transformer):
              def scheduled(self, args):
                  before, after, _, when, _ = args
                  yield before or () if step <= when else after
  
              def alternate(self, args):
                  args = ["" if not arg else arg for arg in args]
                  yield args[(step - 1) % len(args)]
  
              def start(self, args):
                  def flatten(x):
                      if isinstance(x, str):
                          yield x
                      else:
                          for gen in x:
                              yield from flatten(gen)
  
                  return "".join(flatten(args))
  
              def plain(self, args):
                  yield args[0].value
  
              def __default__(self, data, children, meta):
                  for child in children:
                      yield child
  
          return AtStep().transform(tree)
  
      def get_schedule(prompt):
          try:
              tree = schedule_parser.parse(prompt)
          except lark.exceptions.LarkError:
              if 0:
                  import traceback
  
                  traceback.print_exc()
              return [[steps, prompt]]
          return [
              [t, at_step(t, tree)] for t in collect_steps(steps, tree)
          ]
  
      promptdict = {
          prompt: get_schedule(prompt) for prompt in set(prompts)
      }
      return [promptdict[prompt] for prompt in prompts]
  
imports: from __future__ import annotations
  import re
  from collections import namedtuple
  import lark
label_desc: Use image node_id 1 for calling a global function with example usage: get_learned_conditioning_prompt_schedules(prompts, base_steps, hires_steps, use_old_scheduling) and returns: unknown, sorted, AtStep, unknown, str, list