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","."]
code: def __init__(self, config, dataset):
      super(NCL, self).__init__(config, dataset)
  
      # load dataset info
      self.interaction_matrix = dataset.inter_matrix(form="coo").astype(
          np.float32
      )
  
      # load parameters info
      self.latent_dim = config[
          "embedding_size"
      ]  # int type: the embedding size of the base model
      self.n_layers = config[
          "n_layers"
      ]  # int type: the layer num of the base model
      self.reg_weight = config[
          "reg_weight"
      ]  # float32 type: the weight decay for l2 normalization
  
      self.ssl_temp = config["ssl_temp"]
      self.ssl_reg = config["ssl_reg"]
      self.hyper_layers = config["hyper_layers"]
  
      self.alpha = config["alpha"]
  
      self.proto_reg = config["proto_reg"]
      self.k = config["num_clusters"]
  
      # define layers and loss
      self.user_embedding = torch.nn.Embedding(
          num_embeddings=self.n_users, embedding_dim=self.latent_dim
      )
      self.item_embedding = torch.nn.Embedding(
          num_embeddings=self.n_items, embedding_dim=self.latent_dim
      )
  
      self.mf_loss = BPRLoss()
      self.reg_loss = EmbLoss()
  
      # storage variables for full sort evaluation acceleration
      self.restore_user_e = None
      self.restore_item_e = None
  
      self.norm_adj_mat = self.get_norm_adj_mat().to(self.device)
  
      # parameters initialization
      self.apply(xavier_uniform_initialization)
      self.other_parameter_name = ["restore_user_e", "restore_item_e"]
  
      self.user_centroids = None
      self.user_2cluster = None
      self.item_centroids = None
      self.item_2cluster = None
  
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 1 to create a new NCL object from inherited base classes: GeneralRecommender with example: obj = NCL(config, dataset)