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 "net_input" not in sample:
              continue
  
          if cuda:
              s = utils.move_to_cuda(sample)
          else:
              s = sample
          input = s["net_input"]
          srclen = input["src_tokens"].size(1)
          if self.use_char_source:
              encoder_input = {
                  k: v
                  for k, v in input.items()
                  if k
                  in [
                      "src_tokens",
                      "src_lengths",
                      "char_inds",
                      "word_lengths",
                  ]
              }
          else:
              encoder_input = {
                  k: v
                  for k, v in input.items()
                  if k in ["src_tokens", "src_lengths"]
              }
          if timer is not None:
              timer.start()
          with torch.no_grad():
              hypos = self.generate(
                  encoder_input=encoder_input,
                  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"]):
              # remove padding
              src = utils.strip_pad(input["src_tokens"][i, :], self.pad)
              ref = utils.strip_pad(s["target"][i, :], self.pad)
              yield id, src, ref, hypos[i]
  
imports: import math
  from typing import List, Tuple
  import torch
  from fairseq import search, utils
  from fairseq.models import FairseqIncrementalDecoder
  from pytorch_translate import utils
  from torch import Tensor
label_desc: Use image node_id 3 for calling the SequenceGenerator 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