class_docstr: Extension of fairseq.data.LanguagePairDataset where each example
  has a weight in [0.0, 1.0], which will be used to weigh the loss.
  
  TODO: Refactor this class to look like WeightedBacktranslationDataset.
  We could wrap an existing dataset object and provide additional weights
  feature. This way, it will be more composable and can be used with arbitrary
  datasets. See D13143051.
  
  Args:
      weights (list): list of per example weight values; each example
      has a weight in [0.0, 1.0]. Alternatively, when weights consists of a
      single value, that value is broadcast as weight to all examples. [0.0]
      gives 0 weight to all examples.
code: def collate(samples, pad_idx, eos_idx, left_pad_source=False):
      if len(samples) == 0:
          return {}
      unweighted_data = data.language_pair_dataset.collate(
          samples, pad_idx, eos_idx, left_pad_source
      )
      original_weights = torch.FloatTensor(
          [s.get("weight", 1.0) for s in samples]
      )
      # sort by descending source length
      src_lengths = torch.LongTensor(
          [s["source"].numel() for s in samples]
      )
      src_lengths, sort_order = src_lengths.sort(descending=True)
      weights = original_weights.index_select(0, sort_order)
      unweighted_data["weights"] = weights
      return unweighted_data
  
imports: import torch
  from fairseq import data
label_desc: Use image node_id 5 for calling the WeightedLanguagePairDataset obj's underlying member method code with example usage: obj.collate(samples, pad_idx, eos_idx, left_pad_source) and returns: unweighted_data, dict