code: def test_get_best_translations(
      expected_best_ids, expected_best_indices
  ):
      best_hyp_indices = pt.tensor(
          [[0, 1, 0, 1], [0, 1, 1, 0], [2, 3, 2, 3], [2, 3, 3, 2]],
          dtype=pt.int32,
      )
      best_word_indices = pt.tensor(
          [[[3, 3, 0]], [[4, 4, 3]], [[3, 3, 0]], [[4, 5, 3]]],
          dtype=pt.int32,
      )
      seq_scores = pt.tensor(
          [[3.8197377], [5.081118], [3.8068485], [5.0746527]],
          dtype=pt.float32,
      )
      lengths = pt.tensor([[3], [2], [3], [2]], dtype=pt.int32)
  
      translator = mock_translator(beam_size=2, batch_size=2)
  
      expected_result = [
          sockeye.inference.Translator._assemble_translation(*x)
          for x in zip(
              best_word_indices[
                  expected_best_indices,
                  :,
                  np.arange(expected_best_indices.shape[1]),
              ],
              lengths[expected_best_ids],
              seq_scores[expected_best_ids],
              itertools.repeat(None),
          )
      ]
  
      search_result = sockeye.beam_search.SearchResult(
          best_hyp_indices=best_hyp_indices,
          best_word_indices=best_word_indices,
          accumulated_scores=seq_scores,
          lengths=lengths,
          estimated_reference_lengths=None,
      )
      actual_result = (
          sockeye.inference.Translator._get_best_translations(
              translator, search_result
          )
      )
  
      for expected_translation, actual_translation in zip(
          expected_result, actual_result
      ):
          assert (
              expected_translation.target_ids
              == actual_translation.target_ids
          )
          assert (
              expected_translation.scores == actual_translation.scores
          )
  
imports: import itertools
  import json
  from math import ceil
  from unittest.mock import patch, Mock
  import numpy
  import pytest
  import torch
  import sockeye.beam_search
  import sockeye.constants
  import sockeye.data_io
  import sockeye.inference
  import sockeye.lexicon
  import sockeye.model
  import sockeye.utils
label_desc: Use image node_id 16 for calling a global function with example usage: test_get_best_translations(expected_best_ids, expected_best_indices) without return types