class_docstr: Base class for criteria with need to run beam search.
class_docstr_tok: ["Base","class","for","criteria","with","need","to","run","beam","search","."]
docstr: Use beam_size times smaller batch size for translation.
docstr_tok: ["Use","beam_size","times","smaller","batch","size","for","translation","."]
code: def _batch_translations(self, model, enc_input):
      """Use beam_size times smaller batch size for translation."""
      translator = self.get_translator(model)
      bsz = enc_input[1].size(0)
      gen_bsz = bsz // translator.beam_size + 1
      for f in range(0, bsz, gen_bsz):
          t = min(f + gen_bsz, bsz)
          for trans in translator.generate(
              (enc_input[0][f:t], enc_input[1][f:t])
          ):
              yield trans
  
imports: import copy
  import math
  import torch
  from fairseq import utils
  from fairseq.criterions import LegacyFairseqCriterion, register_criterion
  from fairseq.scoring import bleu
  from pytorch_translate import generate
label_desc: Use image node_id 4 for calling the BaseSequenceLossCriterion obj's underlying member method code with example usage: obj._batch_translations(model, enc_input) without return types