class_docstr: Data collator used denoising language modeling task in BART.
  The implementation is based on
  https://github.com/pytorch/fairseq/blob/1bba712622b8ae4efb3eb793a8a40da386fe11d0/fairseq/data/denoising_dataset.py.
  
  BART Original hyperparams: https://github.com/facebookresearch/fairseq/issues/1899#issuecomment-1069429320
docstr: Batching, adding whole word mask and permutate sentences
  Args:
      samples (dict): list of samples each samples contains input_ids field
code: def __call__(
      self, samples: List[Dict[str, List[int]]]
  ) -> Dict[str, torch.Tensor]:
      """Batching, adding whole word mask and permutate sentences
      Args:
          samples (dict): list of samples each samples contains input_ids field
      """
      # Handle dict or lists with proper padding and conversion to tensor.
      batch = {}
      source_text = [sample["source_text"] for sample in samples]
      source_ids = self.tokenizer(
          source_text,
          max_length=self.config["src_len"],
          truncation=True,
          padding=True,
          return_attention_mask=False,
          return_tensors="pt",
      )["input_ids"]
  
      target_ids = source_ids.clone()
      target_ids[
          torch.eq(target_ids, self.tokenizer.pad_token_id)
      ] = -100
      batch["target_ids"] = target_ids
  
      if self.permutate_sentence_ratio:
          new_source_text = []
          for text in source_text:
              texts = sent_tokenize(text)
              random.shuffle(texts)
              new_source_text.append(" ".join(texts))
          source_ids = self.tokenizer(
              new_source_text,
              max_length=self.config["src_len"],
              truncation=True,
              padding=True,
              return_attention_mask=False,
              return_tensors="pt",
          )["input_ids"]
  
      if self.mask_ratio > 0.0:
          source_ids = self.add_whole_word_mask(source_ids)
  
      batch["source_ids"] = source_ids
      batch["source_mask"] = source_ids.ne(self.tokenizer.pad_token_id)
  
      return batch
  
file_path: TextBox/textbox/data/denoising_dataset.py
imports: import math
  import torch
  import random
  from typing import List, Dict
  from nltk import sent_tokenize
  from textbox.data.misc import _pad_sequence
label_desc: Use image node_id 4 for calling the DenoisingCollate obj's underlying member method code with example usage: obj.__call__(samples) and returns: batch