class_docstr: NCL is a neighborhood-enriched contrastive learning paradigm for graph collaborative filtering.
  Both structural and semantic neighbors are explicitly captured as contrastive learning objects.
class_docstr_tok: ["NCL","is","a","neighborhood-enriched","contrastive","learning","paradigm","for","graph","collaborative","filtering",".","Both","structural","and","semantic","neighbors","are","explicitly","captured","as","contrastive","learning","objects","."]
docstr: Run K-means algorithm to get k clusters of the input tensor x
docstr_tok: ["Run","K-means","algorithm","to","get","k","clusters","of","the","input","tensor","x"]
code: def run_kmeans(self, x):
      """Run K-means algorithm to get k clusters of the input tensor x"""
      import faiss
  
      kmeans = faiss.Kmeans(d=self.latent_dim, k=self.k, gpu=True)
      kmeans.train(x)
      cluster_cents = kmeans.centroids
  
      _, I = kmeans.index.search(x, 1)
  
      # convert to cuda Tensors for broadcast
      centroids = torch.Tensor(cluster_cents).to(self.device)
      centroids = F.normalize(centroids, p=2, dim=1)
  
      node2cluster = torch.LongTensor(I).squeeze().to(self.device)
      return centroids, node2cluster
  
imports: import numpy
  import scipy.sparse
  import torch
  import torch.nn.functional
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.init import xavier_uniform_initialization
  from recbole.model.loss import BPRLoss, EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 3 for calling the NCL obj's underlying member method code with example usage: obj.run_kmeans(x) and returns: centroids,  node2cluster