code: def numpy_topk(
      scores: onp.ndarray, k: int, offset: onp.ndarray
  ) -> Tuple[onp.ndarray, onp.ndarray, onp.ndarray]:
      """
      Get the lowest k elements per sentence from a `scores` matrix using an intermediary Numpy conversion.
      This should be equivalent to sockeye.utils.topk() and is used as a comparative implementation in testing.
  
      :param scores: Vocabulary scores for the next beam step. (batch_size * beam_size, target_vocabulary_size)
      :param k: The number of smallest scores to return.
      :param offset: Array to add to the hypothesis indices for offsetting in batch decoding.
      :return: The row indices, column indices and values of the k smallest items in matrix.
      """
      # (batch_size, beam_size * target_vocab_size)
      folded_scores = scores.reshape((-1, k * scores.shape[-1]))
      batch_size = folded_scores.shape[0]
  
      # Get the scores
      # Indexes into folded_scores: (batch_size, beam_size)
      flat_idxs = onp.argpartition(folded_scores, range(k))[:, :k]
      # Score values: (batch_size, beam_size)
      values = onp.array(
          folded_scores[
              onp.arange(folded_scores.shape[0])[:, None], flat_idxs
          ]
      )
      best_hyp_indices, best_word_indices = onp.array(
          onp.unravel_index(onp.ravel(flat_idxs), scores.shape),
          dtype="int32",
      )
  
      if batch_size > 1:
          # Offsetting the indices to match the shape of the scores matrix
          best_hyp_indices += offset
  
      values = values.reshape((-1, 1))
      return best_hyp_indices, best_word_indices, values
  
imports: from typing import List, Optional
  from typing import Tuple
  import numpy
  import pytest
  import torch
  import numpy
  import sockeye.beam_search
  import sockeye.constants
  import sockeye.lexicon
  import sockeye.utils
label_desc: Use image node_id 8 for calling a global function with example usage: numpy_topk(scores, k, offset) and returns: best_hyp_indices,  best_word_indices,  values