docs: def main():
      """
      Launches translation (inference).
      Inference is executed on a single GPU, implementation supports beam search
      with length normalization and coverage penalty.
      """
      args = parse_args()
      utils.set_device(args.cuda, args.local_rank)
      utils.init_distributed(args.cuda)
      setup_logging()
  
      if args.env:
          utils.log_env_info()
  
      logging.info(f'Run arguments: {args}')
  
      if not args.cuda and torch.cuda.is_available():
          warnings.warn('cuda is available but not enabled')
      if not args.cudnn:
          torch.backends.cudnn.enabled = False
  
      # load checkpoint and deserialize to CPU (to save GPU memory)
      checkpoint = torch.load(args.model, map_location={'cuda:0': 'cpu'})
  
      # build GNMT model
      tokenizer = Tokenizer()
      tokenizer.set_state(checkpoint['tokenizer'])
      vocab_size = tokenizer.vocab_size
      model_config = checkpoint['model_config']
      model_config['batch_first'] = args.batch_first
      model = GNMT(vocab_size=vocab_size, **model_config)
      model.load_state_dict(checkpoint['state_dict'])
  
      for (math, batch_size, beam_size) in product(args.math, args.batch_size,
                                                   args.beam_size):
          logging.info(f'math: {math}, batch size: {batch_size}, '
                       f'beam size: {beam_size}')
          if math == 'fp32':
              dtype = torch.FloatTensor
          if math == 'fp16':
              dtype = torch.HalfTensor
          model.type(dtype)
  
          if args.cuda:
              model = model.cuda()
          model.eval()
  
          # construct the dataset
          test_data = TextDataset(src_fname=args.input,
                                  tokenizer=tokenizer,
                                  sort=args.sort)
  
          # build the data loader
          test_loader = test_data.get_loader(batch_size=batch_size,
                                             batch_first=args.batch_first,
                                             shuffle=False,
                                             pad=True,
                                             num_workers=0)
  
          # build the translator object
          translator = Translator(model=model,
                                  tokenizer=tokenizer,
                                  loader=test_loader,
                                  beam_size=beam_size,
                                  max_seq_len=args.max_seq_len,
                                  len_norm_factor=args.len_norm_factor,
                                  len_norm_const=args.len_norm_const,
                                  cov_penalty_factor=args.cov_penalty_factor,
                                  cuda=args.cuda,
                                  print_freq=args.print_freq,
                                  dataset_dir=args.dataset_dir)
  
          # execute the inference
          translator.run(calc_bleu=args.bleu, eval_path=args.output,
                         reference_path=args.reference, summary=True)