original_docstring: 
      Reads from either a file or stdin and translates each line, calling the output_handler with the result.
  
      :param output_handler: Handler that will write output to a stream.
      :param translator: Translator that will translate each line of input.
      :param source: Path to file which will be translated line-by-line if included, if none use stdin.
      
docstring: Reads from either a file or stdin and translates each line, calling the output_handler with the result.
docstring_tokens: Reads from either a file or stdin and translates each line calling the output_handler with the result .
code: def read_and_translate(translator: sockeye.inference.Translator, output_handler: sockeye.output_handler.OutputHandler,
                         source: Optional[str] = None) -> None:
      """
      Reads from either a file or stdin and translates each line, calling the output_handler with the result.
  
      :param output_handler: Handler that will write output to a stream.
      :param translator: Translator that will translate each line of input.
      :param source: Path to file which will be translated line-by-line if included, if none use stdin.
      """
  
      source_data = sys.stdin if source is None else sockeye.data_io.smart_open(source)
  
      logger.info("Translating...")
  
      i, total_time = translate_lines(output_handler, source_data, translator)
  
      if i != 0:
          logger.info("Processed %d lines. Total time: %.4f sec/sent: %.4f sent/sec: %.4f", i, total_time,
                      total_time / i, i / total_time)
      else:
          logger.info("Processed 0 lines.")
code_tokens: def read_and_translate ( translator : sockeye . inference . Translator , output_handler : sockeye . output_handler . OutputHandler , source : Optional [ str ] = None ) -> None : source_data = sys . stdin if source is None else sockeye . data_io . smart_open ( source ) logger . info ( "Translating..." ) i , total_time = translate_lines ( output_handler , source_data , translator ) if i != 0 : logger . info ( "Processed %d lines. Total time: %.4f sec/sent: %.4f sent/sec: %.4f" , i , total_time , total_time / i , i / total_time ) else : logger . info ( "Processed 0 lines." )
short_docstring: Reads from either a file or stdin and translates each line, calling the output_handler with the result.
short_docstring_tokens: Reads from either a file or stdin and translates each line calling the output_handler with the result .
comment: """
      Reads from either a file or stdin and translates each line, calling the output_handler with the result.
  
      :param output_handler: Handler that will write output to a stream.
      :param translator: Translator that will translate each line of input.
      :param source: Path to file which will be translated line-by-line if included, if none use stdin.
      """