class_docstr: Designed for classification tasks such as intent/domain classification as well as slot tagging
  
  Dataset Class 
      1. Performs Model-dependent (but Data-independent) operations (tokenization etc)
      2. This can allow the same model preprocessing for multiple datasources
      3. Users can configurate which labels to use for modelling 
          (e.g. intent classification, slot filling or both together etc)
class_docstr_tok: ["Designed","for","classification","tasks","such","as","intent\/domain","classification","as","well","as","slot","tagging","Dataset","Class","1",".","Performs","Model-dependent","(","but","Data-independent",")","operations","(","tokenization","etc",")","2",".","This","can","allow","the","same","model","preprocessing","for","multiple","datasources","3",".","Users","can","configurate","which","labels","to","use","for","modelling","(","e.g",".","intent","classification",",","slot","filling","or","both","together","etc",")"]
docstr: Truncates elements to max length in batch
docstr_tok: ["Truncates","elements","to","max","length","in","batch"]
code: def collate_fn(self, batch):
      """
      Truncates elements to max length in batch
      """
      _, _, _, _, candidate_attn_masks, _, _, _ = zip(*batch)
      # determine max length in batch
      batch_max_length = 0
      for candidate_attn_mask in candidate_attn_masks:
          for one_attn_mask in candidate_attn_mask:
              batch_max_length = max(
                  batch_max_length, torch.sum(one_attn_mask).item()
              )
      # padding for tp=2 situation
      if batch_max_length % 2:
          batch_max_length += 1
  
      all_items = []
      for item in zip(*batch):
          if isinstance(item[0], int):
              item = [torch.tensor(i) for i in item]
          item_stack = torch.stack(item)
          # if item_stack is 1d, elements refers to indexes and there is no need to truncate
          if len(item_stack.size()) == 1:
              all_items.append(item_stack)
          # otherwise, truncate last dimension to max length in batch
          else:
              all_items.append(item_stack[..., :batch_max_length])
      return all_items
  
file_path: NeMo/nemo/collections/nlp/data/dialogue/dataset/dialogue_gpt_classification_dataset.py
imports: import copy
  import random
  from collections import defaultdict
  import torch
  from nemo.collections.nlp.data.dialogue.dataset.dialogue_dataset import DialogueDataset
  from nemo.utils import logging
label_desc: Use image node_id 11 for calling the DialogueGPTClassificationDataset obj's underlying member method code with example usage: obj.collate_fn(batch) and returns: all_items