class_docstr: Basic class of models
  
  Attributes:
      hparams (HParams): A HParams object, holds the entire set of hyperparameters.
      train_iterator (object): An iterator to load the data in training steps.
      test_iterator (object): An iterator to load the data in testing steps.
      graph (object): An optional graph.
      seed (int): Random seed.
class_docstr_tok: ["Basic","class","of","models","Attributes",":","hparams","(","HParams",")",":","A","HParams","object",",","holds","the","entire","set","of","hyperparameters",".","train_iterator","(","object",")",":","An","iterator","to","load","the","data","in","training","steps",".","test_iterator","(","object",")",":","An","iterator","to","load","the","data","in","testing","steps",".","graph","(","object",")",":","An","optional","graph",".","seed","(","int",")",":","Random","seed","."]
docstr: Initializing the model. Create common logics which are needed by all deeprec models, such as loss function,
  parameter set.
  
  Args:
      hparams (HParams): A HParams object, holds the entire set of hyperparameters.
      iterator_creator (object): An iterator to load the data.
      graph (object): An optional graph.
      seed (int): Random seed.
docstr_tok: ["Initializing","the","model",".","Create","common","logics","which","are","needed","by","all","deeprec","models",",","such","as","loss","function",",","parameter","set",".","Args",":","hparams","(","HParams",")",":","A","HParams","object",",","holds","the","entire","set","of","hyperparameters",".","iterator_creator","(","object",")",":","An","iterator","to","load","the","data",".","graph","(","object",")",":","An","optional","graph",".","seed","(","int",")",":","Random","seed","."]
code: def __init__(
      self,
      hparams,
      iterator_creator,
      seed=None,
  ):
      """Initializing the model. Create common logics which are needed by all deeprec models, such as loss function,
      parameter set.
  
      Args:
          hparams (HParams): A HParams object, holds the entire set of hyperparameters.
          iterator_creator (object): An iterator to load the data.
          graph (object): An optional graph.
          seed (int): Random seed.
      """
      self.seed = seed
      tf.compat.v1.set_random_seed(seed)
      np.random.seed(seed)
  
      self.train_iterator = iterator_creator(
          hparams,
          hparams.npratio,
          col_spliter="\t",
      )
      self.test_iterator = iterator_creator(
          hparams,
          col_spliter="\t",
      )
  
      self.hparams = hparams
      self.support_quick_scoring = hparams.support_quick_scoring
  
      # set GPU use with on demand growth
      gpu_options = tf.compat.v1.GPUOptions(allow_growth=True)
      sess = tf.compat.v1.Session(
          config=tf.compat.v1.ConfigProto(gpu_options=gpu_options)
      )
  
      # set this TensorFlow session as the default session for Keras
      tf.compat.v1.keras.backend.set_session(sess)
  
      # IMPORTANT: models have to be loaded AFTER SETTING THE SESSION for keras!
      # Otherwise, their weights will be unavailable in the threads after the session there has been set
      self.model, self.scorer = self._build_graph()
  
      self.loss = self._get_loss()
      self.train_optimizer = self._get_opt()
  
      self.model.compile(loss=self.loss, optimizer=self.train_optimizer)
  
imports: import abc
  import time
  import numpy
  from tqdm import tqdm
  import tensorflow
  from tensorflow.compat.v1 import keras
  from recommenders.models.deeprec.deeprec_utils import cal_metric
label_desc: Use image node_id 1 to create a new BaseModel object  with example: obj = BaseModel(hparams, iterator_creator, seed)