class_docstr: ## Function to load data into batches
class_docstr_tok: ["#","#","Function","to","load","data","into","batches"]
docstr: * `batch` is the batch of data collected by the `DataLoader`
docstr_tok: ["*","`","batch","`","is","the","batch","of","data","collected","by","the","`","DataLoader","`"]
code: def __call__(self, batch):
      """
      * `batch` is the batch of data collected by the `DataLoader`
      """
  
      # Input data tensor, initialized with `padding_token`
      data = torch.full(
          (self.seq_len, len(batch)),
          self.padding_token,
          dtype=torch.long,
      )
      # Empty labels tensor
      labels = torch.zeros(len(batch), dtype=torch.long)
  
      # Loop through the samples
      for i, (_label, _text) in enumerate(batch):
          # Set the label
          labels[i] = int(_label) - 1
          # Tokenize the input text
          _text = [self.vocab[token] for token in self.tokenizer(_text)]
          # Truncate upto `seq_len`
          _text = _text[: self.seq_len]
          # Transpose and add to data
          data[: len(_text), i] = data.new_tensor(_text)
  
      # Set the final token in the sequence to `[CLS]`
      data[-1, :] = self.classifier_token
  
      #
      return data, labels
  
imports: from collections import Counter
  from typing import Callable
  import torch
  import torchtext
  from torch import nn
  from torch.utils.data import DataLoader
  import torchtext.vocab
  from torchtext.vocab import Vocab
  from labml import lab, tracker, monit
  from labml.configs import option
  from labml_helpers.device import DeviceConfigs
  from labml_helpers.metrics.accuracy import Accuracy
  from labml_helpers.module import Module
  from labml_helpers.train_valid import TrainValidConfigs, hook_model_outputs, BatchIndex
  from labml_nn.optimizers.configs import OptimizerConfigs
label_desc: Use image node_id 2 for calling the CollateFunc obj's underlying member method code with example usage: obj.__call__(batch) and returns: data,  labels