nodes: 0, module; 1, function_definition; 2, function_name:nearest_neighbors; 3, parameters; 4, block; 5, identifier:self; 6, identifier:word; 7, default_parameter; 8, expression_statement; 9, comment:#TODO(rmyeid): Use scikit ball tree, if scikit is available; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, return_statement; 15, identifier:top_k; 16, integer:10; 17, comment:"""Return the nearest k words to the given `word`.
  
      Args:
        word (string): single word.
        top_k (integer): decides how many neighbors to report.
  
      Returns:
        A list of words sorted by the distances. The closest is the first.
  
      Note:
        L2 metric is used to calculate distances.
      """; 18, assignment; 19, assignment; 20, assignment; 21, assignment; 22, list_comprehension; 23, identifier:point; 24, subscript; 25, identifier:diff; 26, binary_operator:self.vectors - point; 27, identifier:distances; 28, call; 29, identifier:top_ids; 30, subscript; 31, subscript; 32, for_in_clause; 33, identifier:self; 34, identifier:word; 35, attribute; 36, identifier:point; 37, attribute; 38, argument_list; 39, call; 40, slice; 41, attribute; 42, identifier:i; 43, identifier:i; 44, identifier:top_ids; 45, identifier:self; 46, identifier:vectors; 47, attribute; 48, identifier:norm; 49, identifier:diff; 50, keyword_argument; 51, attribute; 52, argument_list; 53, integer:1; 54, binary_operator:top_k+1; 55, attribute; 56, identifier:id_word; 57, identifier:np; 58, identifier:linalg; 59, identifier:axis; 60, integer:1; 61, identifier:distances; 62, identifier:argsort; 63, identifier:top_k; 64, integer:1; 65, identifier:self; 66, identifier:vocabulary
code: def nearest_neighbors(self, word, top_k=10):
      """Return the nearest k words to the given `word`.
  
      Args:
        word (string): single word.
        top_k (integer): decides how many neighbors to report.
  
      Returns:
        A list of words sorted by the distances. The closest is the first.
  
      Note:
        L2 metric is used to calculate distances.
      """
      #TODO(rmyeid): Use scikit ball tree, if scikit is available
      point = self[word]
      diff = self.vectors - point
      distances = np.linalg.norm(diff, axis=1)
      top_ids = distances.argsort()[1:top_k+1]
      return [self.vocabulary.id_word[i] for i in top_ids]