class_docstr: Abstraction around providing pattern for interleaving codebooks.
  
  The CodebooksPatternProvider abstraction allows to implement various strategies to
  define interleaving pattern of sequences composed of multiple codebooks. For a given
  number of codebooks `n_q`, the pattern provider can generate a specified pattern
  corresponding to a sequence of `T` timesteps with `n_q` parallel codebooks. This pattern
  can be used to construct a new sequence from the original codes respecting the specified
  pattern. The pattern is defined as a list of list of code coordinates, code coordinate
  being a tuple with the original timestep and codebook to build the new sequence.
  Note that all patterns must start with an empty list that is then used to insert a first
  sequence step of special tokens in the newly generated sequence.
  
  Args:
      n_q (int): number of codebooks.
      cached (bool): if True, patterns for a given length are cached. In general
          that should be true for efficiency reason to avoid synchronization points.
class_docstr_tok: ["Abstraction","around","providing","pattern","for","interleaving","codebooks",".","The","CodebooksPatternProvider","abstraction","allows","to","implement","various","strategies","to","define","interleaving","pattern","of","sequences","composed","of","multiple","codebooks",".","For","a","given","number","of","codebooks","`","n_q","`",",","the","pattern","provider","can","generate","a","specified","pattern","corresponding","to","a","sequence","of","`","T","`","timesteps","with","`","n_q","`","parallel","codebooks",".","This","pattern","can","be","used","to","construct","a","new","sequence","from","the","original","codes","respecting","the","specified","pattern",".","The","pattern","is","defined","as","a","list","of","list","of","code","coordinates",",","code","coordinate","being","a","tuple","with","the","original","timestep","and","codebook","to","build","the","new","sequence",".","Note","that","all","patterns","must","start","with","an","empty","list","that","is","then","used","to","insert","a","first","sequence","step","of","special","tokens","in","the","newly","generated","sequence",".","Args",":","n_q","(","int",")",":","number","of","codebooks",".","cached","(","bool",")",":","if","True",",","patterns","for","a","given","length","are","cached",".","In","general","that","should","be","true","for","efficiency","reason","to","avoid","synchronization","points","."]
docstr: Builds pattern with specific interleaving between codebooks.
  
  Args:
      timesteps (int): Total number of timesteps.
docstr_tok: ["Builds","pattern","with","specific","interleaving","between","codebooks",".","Args",":","timesteps","(","int",")",":","Total","number","of","timesteps","."]
code: def get_pattern(self, timesteps: int) -> Pattern:
      """Builds pattern with specific interleaving between codebooks.
  
      Args:
          timesteps (int): Total number of timesteps.
      """
      raise NotImplementedError()
  
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 CodebooksPatternProvider obj's underlying member method code with example usage: obj.get_pattern(timesteps) without return types