docstr: Generates encoding graph given a cornac data set
  
  Parameters
  ----------
  data_set : cornac.data.dataset.Dataset
      The data set as provided by cornac
  
  add_support : bool, optional
docstr_tok: ["Generates","encoding","graph","given","a","cornac","data","set","Parameters","--","--","--","--","--","data_set",":","cornac.data.dataset.Dataset","The","data","set","as","provided","by","cornac","add_support",":","bool",",","optional"]
code: def _generate_enc_graph(self, data_set, add_support=False):
      """
      Generates encoding graph given a cornac data set
  
      Parameters
      ----------
      data_set : cornac.data.dataset.Dataset
          The data set as provided by cornac
  
      add_support : bool, optional
      """
      data_dict = {}
      num_nodes_dict = {
          "user": self.total_users,
          "item": self.total_items,
      }
      rating_row, rating_col, rating_values = data_set.uir_tuple
      for rating in set(rating_values):
          ridx = np.where(rating_values == rating)
          rrow = rating_row[ridx]
          rcol = rating_col[ridx]
          rating = str(rating).replace(".", "_")
          data_dict.update(
              {
                  ("user", str(rating), "item"): (rrow, rcol),
                  ("item", f"rev-{str(rating)}", "user"): (rcol, rrow),
              }
          )
  
      graph = dgl.heterograph(data_dict, num_nodes_dict=num_nodes_dict)
  
      # sanity check
      assert (
          len(data_set.uir_tuple[2])
          == sum([graph.num_edges(et) for et in graph.etypes]) // 2
      )
  
      graph = self._apply_support(graph) if add_support else graph
  
      return graph
  
imports: import logging
  import time
  from collections import defaultdict
  import torch
  from torch import nn
  import dgl
  import numpy
  import scipy.sparse
  from tqdm import tqdm
  from .nn_modules import NeuralNetwork
  from .utils import get_optimizer, torch_net_info, torch_total_param_num
label_desc: Use image node_id 3 for calling the Model obj's underlying member method code with example usage: obj._generate_enc_graph(data_set, add_support) and returns: graph