docstr: Convert a Seq2SeqLMBatch to a text_generation_server.v1.CachedBatch protobuf
docstr_tok: ["Convert","a","Seq2SeqLMBatch","to","a","text_generation_server.v1.CachedBatch","protobuf"]
code: def to_pb(self) -> generate_pb2.CachedBatch:
      """Convert a Seq2SeqLMBatch to a text_generation_server.v1.CachedBatch protobuf"""
      return generate_pb2.CachedBatch(
          id=self.batch_id,
          request_ids=[r.id for r in self.requests],
          size=len(self),
          max_tokens=self.max_tokens,
      )
  
imports: import torch
  import time
  from dataclasses import dataclass
  from opentelemetry import trace
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, PreTrainedTokenizerBase
  from typing import Optional, Tuple, List, Type, Dict
  from text_generation_server.utils.tokens import batch_top_tokens
  from text_generation_server.models import Model
  from text_generation_server.models.types import GeneratedText, Batch, Generation, Tokens
  from text_generation_server.pb import generate_pb2
  from text_generation_server.utils import NextTokenChooser, StoppingCriteria, Sampling
label_desc: Use image node_id 1 for calling the Seq2SeqLMBatch obj's underlying member method code with example usage: obj.to_pb() and returns: generate_pb2