code: def nearest_k(
      similarity_matrix: pt.Tensor,
      query_word_id: int,
      k: int,
      gamma: float = 1.0,
  ) -> Iterable[Tuple[int, float]]:
      """
      Returns values and indices of k items with largest similarity.
  
      :param similarity_matrix: Similarity matrix.
      :param query_word_id: Query word id.
      :param k: Number of closest items to retrieve.
      :param gamma: Parameter to control distribution steepness.
      :return: List of indices and values of k nearest elements.
      """
      # pylint: disable=unbalanced-tuple-unpacking
      values, indices = pt.topk(
          (similarity_matrix[query_word_id] / gamma).softmax(0), k=k
      )
      return zip(indices.tolist(), values.tolist())
  
file_path: sockeye/sockeye/embeddings.py
imports: import argparse
  import logging
  import sys
  from typing import Iterable, Tuple
  import torch
  import sockeye.constants
  from .None import model
  from .None import utils
  from .data_io import tokens2ids
  from .log import setup_main_logger
  from .utils import check_condition
  from .vocab import reverse_vocab
label_desc: Use image node_id 2 for calling a global function with example usage: nearest_k(similarity_matrix, query_word_id, k, gamma) and returns: zip