docstr: Iterate over a batched dataset and yield individual translations.
  
  Args:
      maxlen_a/b: generate sequences of maximum length ax + b,
          where x is the source sentence length.
      cuda: use GPU for generation
      timer: StopwatchMeter for timing generations.
docstr_tok: ["Iterate","over","a","batched","dataset","and","yield","individual","translations",".","Args",":","maxlen_a\/b",":","generate","sequences","of","maximum","length","ax","+","b",",","where","x","is","the","source","sentence","length",".","cuda",":","use","GPU","for","generation","timer",":","StopwatchMeter","for","timing","generations","."]
code: def generate_batched_itr(
      self,
      data_itr,
      beam_size=None,
      maxlen_a=0.0,
      maxlen_b=None,
      cuda=False,
      timer=None,
      prefix_size=0,
  ):
      """Iterate over a batched dataset and yield individual translations.
  
      Args:
          maxlen_a/b: generate sequences of maximum length ax + b,
              where x is the source sentence length.
          cuda: use GPU for generation
          timer: StopwatchMeter for timing generations.
      """
      if maxlen_b is None:
          maxlen_b = self.maxlen
  
      for sample in data_itr:
          if cuda:
              s = utils.move_to_cuda(sample)
          input = s["net_input"]
          # Take the max source length to compute the max target length
          srclen = input["src_tokens"].size(1)
          # FIXME: handle characters properly
          if self.use_char_source:
              raise ValueError(
                  "Character level encoder is not supported yet for "
                  "multisource sentences."
              )
          encoder_inputs = (input["src_tokens"], input["src_lengths"])
          if timer is not None:
              timer.start()
          with torch.no_grad():
              hypos = self.generate(
                  encoder_inputs,
                  srcs_ids=input["src_ids"],
                  beam_size=beam_size,
                  maxlen=int(maxlen_a * srclen + maxlen_b),
                  prefix_tokens=s["target"][:, :prefix_size]
                  if prefix_size > 0
                  else None,
              )
          if timer is not None:
              timer.stop(s["ntokens"])
          for i, id in enumerate(s["id"]):
              src = input["src_tokens"].index_select(
                  0, input["src_ids"][self.align_to]
              )
              # remove padding from ref
              ref = utils.strip_pad(s["target"][i, :], self.pad)
              yield id, src, ref, hypos[i]
  
file_path: translate/pytorch_translate/research/multisource/multisource_decode.py
imports: import math
  import torch
  from fairseq import utils
  from fairseq.models import FairseqIncrementalDecoder
label_desc: Use image node_id 3 for calling the MultiSourceSequenceGenerator obj's underlying member method code with example usage: obj.generate_batched_itr(data_itr, beam_size, maxlen_a, maxlen_b, cuda, timer, prefix_size) without return types