class_docstr: Translation rerank task.
  The input can be either (src, tgt) sentence pairs or tgt sentence only.
class_docstr_tok: ["Translation","rerank","task",".","The","input","can","be","either","(","src",",","tgt",")","sentence","pairs","or","tgt","sentence","only","."]
code: def build_dataset_for_inference(
      self, src_tokens, src_lengths, **kwargs
  ):
      assert not self.cfg.include_src or len(src_tokens[0]) == 2
      input_src = None
      if self.cfg.include_src:
          input_src = TokenBlockDataset(
              [t[0] for t in src_tokens],
              [l[0] for l in src_lengths],
              block_size=None,  # ignored for "eos" break mode
              pad=self.source_dictionary.pad(),
              eos=self.source_dictionary.eos(),
              break_mode="eos",
          )
          input_src = PrependTokenDataset(
              input_src, self.dictionary.bos()
          )
          input_src = TruncateDataset(input_src, self.cfg.max_positions)
  
      input_tgt = TokenBlockDataset(
          [t[-1] for t in src_tokens],
          [l[-1] for l in src_lengths],
          block_size=None,  # ignored for "eos" break mode
          pad=self.source_dictionary.pad(),
          eos=self.source_dictionary.eos(),
          break_mode="eos",
      )
      input_tgt = TruncateDataset(input_tgt, self.cfg.max_positions)
      if self.cfg.include_src:
          src_tokens = ConcatSentencesDataset(input_src, input_tgt)
          src_lengths = NumelDataset(input_src, reduce=False)
      else:
          input_tgt = PrependTokenDataset(
              input_tgt, self.dictionary.bos()
          )
          src_tokens = input_tgt
          src_lengths = NumelDataset(src_tokens, reduce=False)
  
      dataset = {
          "id": IdDataset(),
          "net_input": {
              "src_tokens": RightPadDataset(
                  src_tokens,
                  pad_idx=self.source_dictionary.pad(),
              ),
              "src_lengths": src_lengths,
          },
          "nsentences": NumSamplesDataset(),
          "ntokens": NumelDataset(src_tokens, reduce=True),
      }
  
      return NestedDictionaryDataset(
          dataset,
          sizes=[src_tokens.sizes],
      )
  
imports: from dataclasses import dataclass, field
  import itertools
  import logging
  import os
  import numpy
  import torch
  from fairseq.logging import metrics
  from fairseq.data import ConcatDataset, ConcatSentencesDataset, data_utils, Dictionary, IdDataset, indexed_dataset, NestedDictionaryDataset, NumSamplesDataset, NumelDataset, PrependTokenDataset, RawLabelDataset, RightPadDataset, SortDataset, TruncateDataset, TokenBlockDataset
  from fairseq.dataclass import ChoiceEnum, FairseqDataclass
  from fairseq.tasks import FairseqTask, register_task
  from omegaconf import II, MISSING
label_desc: Use image node_id 5 for calling the DiscriminativeRerankingNMTTask obj's underlying member method code with example usage: obj.build_dataset_for_inference(src_tokens, src_lengths) and returns: NestedDictionaryDataset