class_docstr: A cache that grows dynamically as more tokens are generated. This is the default for generative models.
  
  It stores the Key and Value states as a list of tensors, one for each layer. The expected shape for each tensor is
  `[batch_size, num_heads, seq_len, head_dim]`.
class_docstr_tok: ["A","cache","that","grows","dynamically","as","more","tokens","are","generated",".","This","is","the","default","for","generative","models",".","It","stores","the","Key","and","Value","states","as","a","list","of","tensors",",","one","for","each","layer",".","The","expected","shape","for","each","tensor","is","`","[","batch_size",",","num_heads",",","seq_len",",","head_dim","]","`","."]
docstr: Returns the sequence length of the cached states. A layer index can be optionally passed.
docstr_tok: ["Returns","the","sequence","length","of","the","cached","states",".","A","layer","index","can","be","optionally","passed","."]
code: def get_seq_length(self, layer_idx: Optional[int] = 0) -> int:
      """Returns the sequence length of the cached states. A layer index can be optionally passed."""
      if len(self.key_cache) <= layer_idx:
          return 0
      return self.key_cache[layer_idx].shape[-2]
  
imports: from typing import Any, Dict, List, Optional, Tuple
  import torch
label_desc: Use image node_id 6 for calling the DynamicCache obj's underlying member method code with example usage: obj.get_seq_length(layer_idx) and returns: self, int