class_docstr: Provider for delayed pattern across delayed codebooks.
  Codebooks are delayed in the sequence and sequence steps will contain codebooks
  from different timesteps.
  
  Example:
      Taking timesteps=4 and n_q=3, delays=None, the multi-codebook sequence:
      [[1, 2, 3, 4],
      [1, 2, 3, 4],
      [1, 2, 3, 4]]
      The resulting sequence obtained from the returned pattern is:
      [[S, 1, 2, 3, 4],
      [S, S, 1, 2, 3],
      [S, S, S, 1, 2]]
      (with S being a special token)
  
  Args:
      n_q (int): Number of codebooks.
      delays (list of int, optional): Delay for each of the codebooks.
          If delays not defined, each codebook is delayed by 1 compared to the previous one.
      flatten_first (int): Flatten the first N timesteps.
      empty_initial (int): Prepend with N empty list of coordinates.
class_docstr_tok: ["Provider","for","delayed","pattern","across","delayed","codebooks",".","Codebooks","are","delayed","in","the","sequence","and","sequence","steps","will","contain","codebooks","from","different","timesteps",".","Example",":","Taking","timesteps=4","and","n_q=3",",","delays=None",",","the","multi-codebook","sequence",":","[","[","1",",","2",",","3",",","4","]",",","[","1",",","2",",","3",",","4","]",",","[","1",",","2",",","3",",","4","]","]","The","resulting","sequence","obtained","from","the","returned","pattern","is",":","[","[","S",",","1",",","2",",","3",",","4","]",",","[","S",",","S",",","1",",","2",",","3","]",",","[","S",",","S",",","S",",","1",",","2","]","]","(","with","S","being","a","special","token",")","Args",":","n_q","(","int",")",":","Number","of","codebooks",".","delays","(","list","of","int",",","optional",")",":","Delay","for","each","of","the","codebooks",".","If","delays","not","defined",",","each","codebook","is","delayed","by","1","compared","to","the","previous","one",".","flatten_first","(","int",")",":","Flatten","the","first","N","timesteps",".","empty_initial","(","int",")",":","Prepend","with","N","empty","list","of","coordinates","."]
code: def get_pattern(self, timesteps: int) -> Pattern:
      omit_special_token = self.empty_initial < 0
      out: PatternLayout = [] if omit_special_token else [[]]
      max_delay = max(self.delays)
      if self.empty_initial:
          out += [[] for _ in range(self.empty_initial)]
      if self.flatten_first:
          for t in range(min(timesteps, self.flatten_first)):
              for q in range(self.n_q):
                  out.append([LayoutCoord(t, q)])
      for t in range(self.flatten_first, timesteps + max_delay):
          v = []
          for q, delay in enumerate(self.delays):
              t_for_q = t - delay
              if t_for_q >= self.flatten_first:
                  v.append(LayoutCoord(t_for_q, q))
          out.append(v)
      return Pattern(out, n_q=self.n_q, timesteps=timesteps)
  
imports: from collections import namedtuple
  from dataclasses import dataclass
  from functools import lru_cache
  import logging
  import typing
  from abc import ABC, abstractmethod
  import torch
label_desc: Use image node_id 2 for calling the DelayedPatternProvider obj's underlying member method code with example usage: obj.get_pattern(timesteps) and returns: Pattern