class_docstr: A :class:`~fairseq.data.FairseqDataset` wrapper that transform bos on
  collated samples of language pair dataset.
  
  Note that the transformation is applied in :func:`collater`.
  
  Args:
      dataset (~fairseq.data.FairseqDataset): dataset that collates sample into
          LanguagePairDataset schema
      src_eos (int): original source end-of-sentence symbol index to be replaced
      new_src_eos (int, optional): new end-of-sentence symbol index to replace source eos symbol
      tgt_bos (int, optional): original target beginning-of-sentence symbol index to be replaced
      new_tgt_bos (int, optional): new beginning-of-sentence symbol index to replace at the
          beginning of 'prev_output_tokens'
class_docstr_tok: ["A",":","class",":","`","~fairseq.data.FairseqDataset","`","wrapper","that","transform","bos","on","collated","samples","of","language","pair","dataset",".","Note","that","the","transformation","is","applied","in",":","func",":","`","collater","`",".","Args",":","dataset","(","~fairseq.data.FairseqDataset",")",":","dataset","that","collates","sample","into","LanguagePairDataset","schema","src_eos","(","int",")",":","original","source","end-of-sentence","symbol","index","to","be","replaced","new_src_eos","(","int",",","optional",")",":","new","end-of-sentence","symbol","index","to","replace","source","eos","symbol","tgt_bos","(","int",",","optional",")",":","original","target","beginning-of-sentence","symbol","index","to","be","replaced","new_tgt_bos","(","int",",","optional",")",":","new","beginning-of-sentence","symbol","index","to","replace","at","the","beginning","of","'prev_output_tokens","'"]
code: def collater(self, samples, **extra_args):
      samples = self.dataset.collater(samples, **extra_args)
      if len(samples) == 0:
          return samples
  
      if "net_input" not in samples:
          return samples
  
      if self.new_src_eos is not None:
          if self.dataset.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
          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
              eos_idx = eos_idx.resize_(
                  len(samples["net_input"]["src_lengths"]), 1
              )
              samples["net_input"]["src_tokens"].scatter_(
                  1, eos_idx, self.new_src_eos
              )
  
      if (
          self.new_tgt_bos is not None
          and "prev_output_tokens" in samples["net_input"]
      ):
          if self.dataset.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
  
      return samples
  
file_path: fairseq/fairseq/data/transform_eos_lang_pair_dataset.py
imports: from typing import Optional
  import torch
  from .None import FairseqDataset
label_desc: Use image node_id 4 for calling the TransformEosLangPairDataset obj's underlying member method code with example usage: obj.collater(samples) and returns: samples, samples, samples