class_docstr: Class for handling KGE models which follows the ranking based protocol.
  
  Example
  -------
  >>> # create model and compile using user defined optimizer settings and
  >>> # user defined settings of an existing loss
  >>> from ampligraph.datasets import load_fb15k_237
  >>> from ampligraph.latent_features import ScoringBasedEmbeddingModel
  >>> from ampligraph.latent_features.loss_functions import SelfAdversarialLoss
  >>> import tensorflow as tf
  >>> X = load_fb15k_237()
  >>> loss = SelfAdversarialLoss({'margin': 0.1, 'alpha': 5, 'reduction': 'sum'})
  >>> model = ScoringBasedEmbeddingModel(eta=5,
  >>>                                    k=300,
  >>>                                    scoring_type='ComplEx',
  >>>                                    seed=0)
  >>> model.compile(optimizer='adam', loss=loss)
  >>> model.fit(X['train'],
  >>>           batch_size=10000,
  >>>           epochs=5)
  Epoch 1/5
  29/29 [==============================] - 3s 87ms/step - loss: 13496.5752
  Epoch 2/5
  29/29 [==============================] - 1s 36ms/step - loss: 13488.8682
  Epoch 3/5
  29/29 [==============================] - 1s 35ms/step - loss: 13436.2725
  Epoch 4/5
  29/29 [==============================] - 1s 35ms/step - loss: 13259.0840
  Epoch 5/5
  29/29 [==============================] - 1s 34ms/step - loss: 12977.0117
class_docstr_tok: ["Class","for","handling","KGE","models","which","follows","the","ranking","based","protocol",".","Example","--","--","--","-",">",">",">","#","create","model","and","compile","using","user","defined","optimizer","settings","and",">",">",">","#","user","defined","settings","of","an","existing","loss",">",">",">","from","ampligraph.datasets","import","load_fb15k_237",">",">",">","from","ampligraph.latent_features","import","ScoringBasedEmbeddingModel",">",">",">","from","ampligraph.latent_features.loss_functions","import","SelfAdversarialLoss",">",">",">","import","tensorflow","as","tf",">",">",">","X","=","load_fb15k_237","(",")",">",">",">","loss","=","SelfAdversarialLoss","(","{","'margin","'",":","0.1",",","'alpha","'",":","5",",","'reduction","'",":","'sum","'","}",")",">",">",">","model","=","ScoringBasedEmbeddingModel","(","eta=5",",",">",">",">","k=300",",",">",">",">","scoring_type='ComplEx","'",",",">",">",">","seed=0",")",">",">",">","model.compile","(","optimizer='adam","'",",","loss=loss",")",">",">",">","model.fit","(","X","[","'train","'","]",",",">",">",">","batch_size=10000",",",">",">",">","epochs=5",")","Epoch","1\/5","29\/29","[","==============================","]","-","3s","87ms\/step","-","loss",":","13496.5752","Epoch","2\/5","29\/29","[","==============================","]","-","1s","36ms\/step","-","loss",":","13488.8682","Epoch","3\/5","29\/29","[","==============================","]","-","1s","35ms\/step","-","loss",":","13436.2725","Epoch","4\/5","29\/29","[","==============================","]","-","1s","35ms\/step","-","loss",":","13259.0840","Epoch","5\/5","29\/29","[","==============================","]","-","1s","34ms\/step","-","loss",":","12977.0117"]
docstr: Initializes the scoring based embedding model using the user specified scoring function.
  
  Parameters
  ----------
  eta: int
      Num of negatives to use during training per triple.
  k: int
      Embedding size.
  scoring_type: str
      Name of the scoring layer to use.
  
      - ``TransE``  Translating embedding scoring function will be used
      - ``DistMult`` DistMult embedding scoring function will be used
      - ``ComplEx`` ComplEx embedding scoring function will be used
      - ``HolE`` Holograph embedding scoring function will be used
  
  seed: int
      Random seed.
  max_ent_size: int
      Maximum number of entities that can occur in any partition (default: `None`).
  max_rel_size: int
      Maximum number of relations that can occur in any partition (default: `None`).
docstr_tok: ["Initializes","the","scoring","based","embedding","model","using","the","user","specified","scoring","function",".","Parameters","--","--","--","--","--","eta",":","int","Num","of","negatives","to","use","during","training","per","triple",".","k",":","int","Embedding","size",".","scoring_type",":","str","Name","of","the","scoring","layer","to","use",".","-","``","TransE","``","Translating","embedding","scoring","function","will","be","used","-","``","DistMult","``","DistMult","embedding","scoring","function","will","be","used","-","``","ComplEx","``","ComplEx","embedding","scoring","function","will","be","used","-","``","HolE","``","Holograph","embedding","scoring","function","will","be","used","seed",":","int","Random","seed",".","max_ent_size",":","int","Maximum","number","of","entities","that","can","occur","in","any","partition","(","default",":","`","None","`",")",".","max_rel_size",":","int","Maximum","number","of","relations","that","can","occur","in","any","partition","(","default",":","`","None","`",")","."]
code: def __init__(
      self,
      eta,
      k,
      scoring_type="DistMult",
      seed=0,
      max_ent_size=None,
      max_rel_size=None,
  ):
      """
      Initializes the scoring based embedding model using the user specified scoring function.
  
      Parameters
      ----------
      eta: int
          Num of negatives to use during training per triple.
      k: int
          Embedding size.
      scoring_type: str
          Name of the scoring layer to use.
  
          - ``TransE``  Translating embedding scoring function will be used
          - ``DistMult`` DistMult embedding scoring function will be used
          - ``ComplEx`` ComplEx embedding scoring function will be used
          - ``HolE`` Holograph embedding scoring function will be used
  
      seed: int
          Random seed.
      max_ent_size: int
          Maximum number of entities that can occur in any partition (default: `None`).
      max_rel_size: int
          Maximum number of relations that can occur in any partition (default: `None`).
      """
      super(ScoringBasedEmbeddingModel, self).__init__()
      # set the random seed
      tf.random.set_seed(seed)
      np.random.seed(seed)
  
      self.max_ent_size = max_ent_size
      self.max_rel_size = max_rel_size
  
      self.eta = eta
      self.scoring_type = scoring_type
  
      # get the scoring layer
      self.scoring_layer = SCORING_LAYER_REGISTRY[scoring_type](k)
      # get the actual k depending on scoring layer
      # Ex: complex model uses k embeddings for real and k for img side.
      # so internally it has 2*k, whereas transE uses k.
      self.k = k
      self.internal_k = self.scoring_layer.internal_k
  
      # create the corruption generation layer - generates eta corruptions
      # during training
      self.corruption_layer = CorruptionGenerationLayerTrain()
  
      # If it is single partition, assume that you have max_ent_size unique entities
      # This would change if we use partitions: based on which partition is in memory
      # this attribute is used by the corruption_layer to sample eta
      # corruptions
      self.num_ents = self.max_ent_size
  
      # Create the embedding lookup layer.
      # size of entity emb is max_ent_size * k and relation emb is
      # max_rel_size * k
      self.encoding_layer = EmbeddingLookupLayer(
          self.internal_k, self.max_ent_size, self.max_rel_size
      )
  
      # Flag to indicate whether the partitioned training is being done
      self.is_partitioned_training = False
      # Variable related to data indexing (entity to idx mapping)
      self.data_indexer = True
  
      # Flag to indicate whether to include FocusE layer
      self.use_focusE = False
      self.focusE_params = {}
  
      self.is_calibrated = False
      self.is_fitted = False
      self.is_backward = False
  
      self.data_shape = None
  
      self.seed = seed
      self.base_dir = tempfile.gettempdir()
      self.partitioner_metadata = {}
  
imports: import tensorflow
  import copy
  import shelve
  import pickle
  import numpy
  import os
  import tempfile
  import logging
  from ampligraph.evaluation.metrics import mrr_score, hits_at_n_score, mr_score
  from ampligraph.datasets import data_adapter
  from ampligraph.datasets.partitioned_data_manager import PartitionDataManager
  from ampligraph.latent_features.layers.scoring.AbstractScoringLayer import SCORING_LAYER_REGISTRY
  from ampligraph.latent_features.layers.encoding import EmbeddingLookupLayer
  from ampligraph.latent_features.layers.calibration import CalibrationLayer
  from ampligraph.latent_features.layers.corruption_generation import CorruptionGenerationLayerTrain
  from ampligraph.datasets.data_indexer import DataIndexer
  from ampligraph.latent_features import optimizers
  from ampligraph.latent_features import loss_functions
  from ampligraph.evaluation import train_test_split_no_unseen
  from tensorflow.python.keras import callbacks
  from tensorflow.python.keras.engine import training_utils
  from tensorflow.python.eager import def_function
  from tensorflow.python.keras import metrics
  from tensorflow.python.keras.engine import compile_utils
label_desc: Use image node_id 3 to create a new ScoringBasedEmbeddingModel object from inherited base classes: tf.keras with example: obj = ScoringBasedEmbeddingModel(eta, k, scoring_type, seed, max_ent_size, max_rel_size)