class_docstr: Scorer class takes a ScoringModel and uses it to score a stream of parallel sentences.
  It also takes the vocabularies so that the original sentences can be printed out, if desired.
  
  :param model: The model to score with.
  :param batch_scorer: BatchScorer block to score each batch.
  :param source_vocabs: The source vocabularies.
  :param target_vocabs: The target vocabularies.
  :param device: Torch device to load batches to (should be set to model device).
class_docstr_tok: ["Scorer","class","takes","a","ScoringModel","and","uses","it","to","score","a","stream","of","parallel","sentences",".","It","also","takes","the","vocabularies","so","that","the","original","sentences","can","be","printed","out",",","if","desired",".",":","param","model",":","The","model","to","score","with",".",":","param","batch_scorer",":","BatchScorer","block","to","score","each","batch",".",":","param","source_vocabs",":","The","source","vocabularies",".",":","param","target_vocabs",":","The","target","vocabularies",".",":","param","device",":","Torch","device","to","load","batches","to","(","should","be","set","to","model","device",")","."]
code: def score(
      self,
      score_iter: data_io.BaseParallelSampleIter,
      output_handler: OutputHandler,
  ):
      total_time = 0.0
      sentence_no = 0
      batch_no = 0
      for batch_no, batch in enumerate(score_iter, 1):
          batch_tic = time.time()
          batch_scores = self.score_batch(batch)
          batch_time = time.time() - batch_tic
          total_time += batch_time
          for sentno, (source, target, scores) in enumerate(
              zip(
                  batch.source[:, :, 0],
                  batch.target[:, :, 0],
                  batch_scores,
              ),
              1,
          ):
              sentence_no += 1
  
              # Transform arguments in preparation for printing
              source_ids = source.tolist()
              source_tokens = list(
                  data_io.ids2tokens(
                      source_ids,
                      self.source_vocab_inv,
                      self.exclude_list,
                  )
              )
              target_ids = target.tolist()
              target_tokens = list(
                  data_io.ids2tokens(
                      target_ids,
                      self.target_vocab_inv,
                      self.exclude_list,
                  )
              )
              target_string = C.TOKEN_SEPARATOR.join(target_tokens)
  
              # Report a score of -inf for invalid sentence pairs (empty source and/or target)
              if source[0] == C.PAD_ID or target[0] == C.PAD_ID:
                  scores = [-np.inf] * self.num_target_factors
  
              # Output handling routines require us to make use of inference classes.
              output_handler.handle(
                  inference.TranslatorInput(sentence_no, source_tokens),
                  inference.TranslatorOutput(
                      sentence_no,
                      target_string,
                      target_tokens,
                      score=scores[0],
                      factor_scores=scores[1:],
                  ),
                  batch_time,
              )
  
      if sentence_no != 0:
          logger.info(
              "Processed %d lines in %d batches. Total time: %.4f, sec/sent: %.4f, sent/sec: %.4f",
              sentence_no,
              math.ceil(sentence_no / batch_no),
              total_time,
              total_time / sentence_no,
              sentence_no / total_time,
          )
      else:
          logger.info("Processed 0 lines.")
  
imports: import logging
  import math
  import time
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from .None import constants
  from .None import data_io
  from .None import inference
  from .None import vocab
  from .beam_search import CandidateScorer
  from .model import SockeyeModel
  from .output_handler import OutputHandler
label_desc: Use image node_id 3 for calling the Scorer obj's underlying member method code with example usage: obj.score(score_iter, output_handler) without return types