code: def __call__(self, samples):
      batch = {}
      source_text = []
      source_ids = []
      source_mask = []
      source_length = []
      target_text = []
      source_padding_side = (
          "left"
          if not self.paired_text and self.is_casual_model
          else self.tokenizer.padding_side
      )
  
      for sample in samples:
          source_text.append(sample["source_text"])
          if self.paired_text and self.is_casual_model:
              src_id = torch.cat(
                  [sample["source_ids"], sample["target_ids"]]
              )
          else:
              src_id = sample["source_ids"]
          source_ids.append(src_id)
          source_mask.append(torch.ones(len(src_id), dtype=torch.long))
          source_length.append(len(src_id))
          target_text.append(sample["target_text"])
  
      batch["source_text"] = source_text
      batch["source_ids"] = _pad_sequence(
          source_ids, self.tokenizer.pad_token_id, source_padding_side
      )
      batch["source_mask"] = _pad_sequence(
          source_mask, 0, source_padding_side
      )
      batch["source_length"] = torch.tensor(
          source_length, dtype=torch.long
      )
      batch["target_text"] = target_text
  
      if self.paired_text:
          target_ids = []
          for sample in samples:
              if self.is_casual_model:
                  tgt_id = torch.cat(
                      [
                          torch.full(
                              [len(sample["source_ids"])],
                              -100,
                              dtype=torch.long,
                          ),
                          sample["target_ids"],
                      ]
                  )
              else:
                  tgt_id = sample["target_ids"]
              target_ids.append(tgt_id)
          batch["target_ids"] = _pad_sequence(
              target_ids, -100, self.tokenizer.padding_side
          )
      return batch
  
file_path: TextBox/textbox/data/abstract_dataset.py
imports: import os
  import torch, warnings
  import math
  from torch.utils.data import DataLoader, Dataset
  from textbox import CLM_MODELS
  from typing import List
  from torch.nn.utils.rnn import pad_sequence
  from textbox.data.misc import load_data, _pad_sequence
label_desc: Use image node_id 3 for calling the AbstractCollate obj's underlying member method code with example usage: obj.__call__(samples) and returns: batch