class_docstr: NNCF is an neural network enhanced matrix factorization model which also captures neighborhood information.
  We implement the NNCF model with three ways to process neighborhood information.
docstr: Get neighborhood information using knn algorithm.
  Find direct neighbors of each node, if the number of direct neighbors is less than neigh_num,
  add other similar neighbors using knn algorithm.
  Otherwise, select random top k direct neighbors, k equals to the number of neighbors.
  
  Returns:
      torch.IntTensor: The neighborhood nodes of a batch of user or item, shape: [batch_size, neigh_num]
docstr_tok: ["Get","neighborhood","information","using","knn","algorithm",".","Find","direct","neighbors","of","each","node",",","if","the","number","of","direct","neighbors","is","less","than","neigh_num",",","add","other","similar","neighbors","using","knn","algorithm",".","Otherwise",",","select","random","top","k","direct","neighbors",",","k","equals","to","the","number","of","neighbors",".","Returns",":","torch.IntTensor",":","The","neighborhood","nodes","of","a","batch","of","user","or","item",",","shape",":","[","batch_size",",","neigh_num","]"]
code: def get_neigh_knn(self):
      r"""Get neighborhood information using knn algorithm.
      Find direct neighbors of each node, if the number of direct neighbors is less than neigh_num,
      add other similar neighbors using knn algorithm.
      Otherwise, select random top k direct neighbors, k equals to the number of neighbors.
  
      Returns:
          torch.IntTensor: The neighborhood nodes of a batch of user or item, shape: [batch_size, neigh_num]
      """
      inter_M = self.interaction_matrix
      pairs = list(zip(inter_M.row, inter_M.col))
      ui_inters = np.zeros((self.n_users, self.n_items), dtype=np.int8)
  
      for i in range(len(pairs)):
          ui_inters[pairs[i][0], pairs[i][1]] = 1
  
      # Get similar neighbors using knn algorithm
      user_knn, _ = ComputeSimilarity(
          self.interaction_matrix.tocsr(), topk=self.neigh_num
      ).compute_similarity("user")
      item_knn, _ = ComputeSimilarity(
          self.interaction_matrix.tocsr(), topk=self.neigh_num
      ).compute_similarity("item")
  
      u_neigh, i_neigh = [], []
  
      for u in range(self.n_users):
          neigh_list = ui_inters[u].nonzero()[0]
          direct_neigh_num = len(neigh_list)
          if len(neigh_list) == 0:
              u_neigh.append(self.neigh_num * [0])
          elif direct_neigh_num < self.neigh_num:
              tmp_k = self.neigh_num - direct_neigh_num
              mask = np.random.randint(0, len(neigh_list), size=1)
              neigh_list = list(neigh_list) + list(
                  item_knn[neigh_list[mask[0]]]
              )
              u_neigh.append(neigh_list[: self.neigh_num])
          else:
              mask = np.random.randint(
                  0, len(neigh_list), size=self.neigh_num
              )
              u_neigh.append(neigh_list[mask])
  
      for i in range(self.n_items):
          neigh_list = ui_inters[:, i].nonzero()[0]
          direct_neigh_num = len(neigh_list)
          if len(neigh_list) == 0:
              i_neigh.append(self.neigh_num * [0])
          elif direct_neigh_num < self.neigh_num:
              tmp_k = self.neigh_num - direct_neigh_num
              mask = np.random.randint(0, len(neigh_list), size=1)
              neigh_list = list(neigh_list) + list(
                  user_knn[neigh_list[mask[0]]]
              )
              i_neigh.append(neigh_list[: self.neigh_num])
          else:
              mask = np.random.randint(
                  0, len(neigh_list), size=self.neigh_num
              )
              i_neigh.append(neigh_list[mask])
  
      u_neigh = torch.tensor(u_neigh, device=self.device)
      i_neigh = torch.tensor(i_neigh, device=self.device)
      return u_neigh, i_neigh
  
imports: import torch
  import torch.nn
  from torch.nn.init import normal_
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.layers import MLPLayers
  from recbole.utils import InputType
  from recbole.model.general_recommender.itemknn import ComputeSimilarity
  import numpy
label_desc: Use image node_id 7 for calling the NNCF obj's underlying member method code with example usage: obj.get_neigh_knn() and returns: u_neigh,  i_neigh