code: def collate_batch(batch):
      label_list, text_list, offsets = [], [], [0]
      for _label, _text in batch:
          label_list.append(label_pipeline(_label))
          processed_text = torch.tensor(
              text_pipeline(_text), dtype=torch.int64
          )
          text_list.append(processed_text)
          offsets.append(processed_text.size(0))
      label_list = torch.tensor(label_list, dtype=torch.int64)
      offsets = torch.tensor(offsets[:-1]).cumsum(dim=0)
      text_list = torch.cat(text_list)
      return (
          label_list.to(device),
          text_list.to(device),
          offsets.to(device),
      )
  
file_path: serve/examples/text_classification/train.py
imports: import os
  import logging
  import argparse
  import time
  from typing import Text
  import torch
  import sys
  from torchtext.utils import download_from_url
  from model import TextSentiment
  from torch.utils.data import DataLoader
  from torch.utils.data.dataset import random_split
  from torchtext.data.functional import to_map_style_dataset
  from torchtext.datasets import DATASETS
  from torchtext.data.utils import get_tokenizer, ngrams_iterator
  from torchtext.vocab import build_vocab_from_iterator
label_desc: Use image node_id 1 for calling a global function with example usage: collate_batch(batch) and returns: label_list,  text_list,  offsets