class_docstr: It is a combination of TransformEosLangPairDataset and ConcatDataset for multiple LangPairDataset datasets.
  Assume all datasets share the same src_eos, tgt_bos, left_pad_source and left_pad_target
code: def collater(self, samples, **extra_args):
      if len(samples) == 0:
          return samples
  
      dataset_ids = [s[0] for s in samples]
      samples = [s[1] for s in samples]
  
      if hasattr(self.datasets[0], "collater"):
          samples = self.datasets[0].collater(samples, **extra_args)
      else:
          samples = default_collate(samples, **extra_args)
  
      if len(self.new_src_eos) > 0:
          if self.left_pad_source:
              assert (
                  samples["net_input"]["src_tokens"][:, -1]
                  != self.src_eos
              ).sum() == 0
              samples["net_input"]["src_tokens"][
                  :, -1
              ] = self.new_src_eos[dataset_ids]
  
          else:
              eos_idx = samples["net_input"]["src_lengths"] - 1
              assert (
                  samples["net_input"]["src_tokens"][
                      torch.arange(eos_idx.size(0)), eos_idx
                  ]
                  != self.src_eos
              ).sum() == 0
              samples["net_input"]["src_tokens"].scatter_(
                  1,
                  eos_idx.view(-1, 1),
                  self.new_src_eos[dataset_ids].view(-1, 1),
              )
  
      if (
          len(self.new_tgt_bos) > 0
          and "prev_output_tokens" in samples["net_input"]
      ):
          if self.left_pad_target:
              # TODO: support different padding direction on target side
              raise NotImplementedError(
                  "TransformEosLangPairDataset does not implement --left-pad-target True option"
              )
          else:
              assert (
                  samples["net_input"]["prev_output_tokens"][:, 0]
                  != self.tgt_bos
              ).sum() == 0
              samples["net_input"]["prev_output_tokens"][
                  :, 0
              ] = self.new_tgt_bos[dataset_ids]
  
      return samples
  
file_path: fairseq/fairseq/data/transform_eos_concat_langpair_dataset.py
imports: import logging
  import torch
  from torch.utils.data.dataloader import default_collate
  from fairseq.data import ConcatDataset
label_desc: Use image node_id 6 for calling the TransformEosConcatLangPairDataset obj's underlying member method code with example usage: obj.collater(samples) and returns: samples, samples