docstr: Create the metadata to track a single sequence in the system.
  
  Arguments:
      tracking_id (int): The slot in the tracking buffers used to track this sequence.
      kv_cache_ids (Tuple[torch.Tensor, ...]): The KV-cache IDs for the sequence. The shape
          of the tensor should be [num_allocation_groups, max_blocks_per_allocation_group].
          There should be one tensor per cache group.
      kv_cache_ids_shadow (Tuple[torch.Tensor, ...]): The shadow tensor for the KV-cache IDs.
          This tensor should be allocated on the host and should have the same shape as the
          tensor provided in ``kv_cache_ids``. There should be one tensor per cache group.
      max_context (int): The maximum number of tokens this sequence may eventually include.
          Currently unused but may be used in future implementations for speculative caching.
docstr_tok: ["Create","the","metadata","to","track","a","single","sequence","in","the","system",".","Arguments",":","tracking_id","(","int",")",":","The","slot","in","the","tracking","buffers","used","to","track","this","sequence",".","kv_cache_ids","(","Tuple","[","torch.Tensor",",","...","]",")",":","The","KV-cache","IDs","for","the","sequence",".","The","shape","of","the","tensor","should","be","[","num_allocation_groups",",","max_blocks_per_allocation_group","]",".","There","should","be","one","tensor","per","cache","group",".","kv_cache_ids_shadow","(","Tuple","[","torch.Tensor",",","...","]",")",":","The","shadow","tensor","for","the","KV-cache","IDs",".","This","tensor","should","be","allocated","on","the","host","and","should","have","the","same","shape","as","the","tensor","provided","in","``","kv_cache_ids","``",".","There","should","be","one","tensor","per","cache","group",".","max_context","(","int",")",":","The","maximum","number","of","tokens","this","sequence","may","eventually","include",".","Currently","unused","but","may","be","used","in","future","implementations","for","speculative","caching","."]
code: def __init__(
      self,
      tracking_id: int,
      kv_cache_ids: Tuple[torch.Tensor, ...],
      kv_cache_ids_shadow: Tuple[torch.Tensor, ...],
      max_context: int = -1,
  ) -> None:
      """
      Create the metadata to track a single sequence in the system.
  
      Arguments:
          tracking_id (int): The slot in the tracking buffers used to track this sequence.
          kv_cache_ids (Tuple[torch.Tensor, ...]): The KV-cache IDs for the sequence. The shape
              of the tensor should be [num_allocation_groups, max_blocks_per_allocation_group].
              There should be one tensor per cache group.
          kv_cache_ids_shadow (Tuple[torch.Tensor, ...]): The shadow tensor for the KV-cache IDs.
              This tensor should be allocated on the host and should have the same shape as the
              tensor provided in ``kv_cache_ids``. There should be one tensor per cache group.
          max_context (int): The maximum number of tokens this sequence may eventually include.
              Currently unused but may be used in future implementations for speculative caching.
      """
      self._tracking_id = tracking_id
      self._kv_cache_ids = kv_cache_ids
      self._kv_cache_ids_shadow = kv_cache_ids_shadow
      self._max_context = max_context
      self._n_cache_groups = len(kv_cache_ids)
  
      self._seen_tokens = 0
      self._in_flight_tokens = 0
  
      self._num_allocation_groups = tuple(
          kv_cache_ids_shadow.shape[0]
          for kv_cache_ids_shadow in kv_cache_ids_shadow
      )
      self._blocks_per_allocation_group = tuple(
          torch.zeros(num_groups, dtype=torch.int32, device="cpu")
          for num_groups in self._num_allocation_groups
      )
  
      for cache_group, kv_cache_ids in enumerate(kv_cache_ids):
          assert (
              self._num_allocation_groups[cache_group]
              == kv_cache_ids.shape[0]
          )
          assert len(kv_cache_ids.shape) == 2
  
imports: from typing import List, Tuple, Union
  import torch
label_desc: Use image node_id 1 to create a new DSSequenceDescriptor object from inherited base classes: BaseSequenceDescriptor with example: obj = DSSequenceDescriptor(tracking_id, kv_cache_ids, kv_cache_ids_shadow, max_context)