class_docstr: Dimensioning properties
docstr: See ``DSInferenceModelBase.get_kv_requirements`` for documentation.
  
  This method assumes an autoregressive dense attention pattern. Override this method
  if this does not match the model's attention pattern.
docstr_tok: ["See","``","DSInferenceModelBase.get_kv_requirements","``","for","documentation",".","This","method","assumes","an","autoregressive","dense","attention","pattern",".","Override","this","method","if","this","does","not","match","the","model","'s","attention","pattern","."]
code: def get_kv_requirements(
      self,
      sequence: DSSequenceDescriptor,
      max_new_tokens: int,
      max_new_blocks: int,
  ) -> Tuple[int, torch.Tensor]:
      """
      See ``DSInferenceModelBase.get_kv_requirements`` for documentation.
  
      This method assumes an autoregressive dense attention pattern. Override this method
      if this does not match the model's attention pattern.
      """
      total_tokens = sequence.seen_tokens + max_new_tokens
      req_blocks = ceil_div(total_tokens, self.attn.kv_block_size)
      block_lim = req_blocks - sequence.cur_allocated_blocks
  
      if block_lim <= max_new_blocks:
          return max_new_tokens, block_lim
  
      token_capacity = (
          max_new_blocks + sequence.cur_allocated_blocks
      ) * self.attn.kv_block_size - sequence.seen_tokens
  
      return token_capacity, torch.tensor([max_new_blocks])
  
imports: from abc import abstractmethod
  from typing import Optional
  import torch
  from deepspeed.accelerator import get_accelerator
  from ..config_v2 import RaggedInferenceEngineConfig
  from ..inference_utils import ActivationType, ceil_div, is_gated
  from ..model_implementations import *
  from ..model_implementations.sharding import *
  from ..modules.configs import DSEmbeddingsConfig, DSLinearConfig, DSMoEConfig, DSNormConfig, DSSelfAttentionConfig, DSUnembedConfig, NormTypeEnum, PositionalEmbeddingType
  from ..modules import heuristics
  from ..ragged import DSSequenceDescriptor, KVCacheConfig, RaggedBatchWrapper
  from .inference_model_base import DSInferenceModelBase, DSModelImplementationConfig, MPType
  from ..inference_parameter import InferenceParameter
label_desc: Use image node_id 24 for calling the DSTransformerModelBase obj's underlying member method code with example usage: obj.get_kv_requirements(sequence, max_new_tokens, max_new_blocks) and returns: token_capacity,  torch, max_new_tokens,  block_lim