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: Compute scores of the input triples.
  
  Parameters
  -----------
  x: np.array, shape (n, 3) or str or GraphDataLoader or AbstractGraphPartitioner
      Data OR Filename of the data file OR Data Handle to be used for training.
  batch_size: int
      Batch size to use during training.
      May be overridden if ``x`` is `GraphDataLoader` or `AbstractGraphPartitioner` instance
  verbose: bool
      Verbosity mode.
  callbacks: list of keras.callbacks.Callback instances
      List of callbacks to apply during evaluation.
  
  Returns
  -------
  scores: np.array, shape (n, )
      Score of the input triples.
  
  Example
  -------
  >>> from ampligraph.latent_features import ScoringBasedEmbeddingModel
  >>> import numpy as np
  >>> from ampligraph.datasets import load_fb15k_237
  >>> X = load_fb15k_237()
  >>> model = ScoringBasedEmbeddingModel(eta=5,
  >>>                                    k=300,
  >>>                                    scoring_type='ComplEx',
  >>>                                    seed=0)
  >>> model.compile(optimizer='adam', loss='nll')
  >>> model.fit(X['train'],
  >>>           batch_size=10000,
  >>>           epochs=5)
  Epoch 1/5
  29/29 [==============================] - 7s 228ms/step - loss: 67361.2734
  Epoch 2/5
  29/29 [==============================] - 5s 184ms/step - loss: 67318.8203
  Epoch 3/5
  29/29 [==============================] - 5s 187ms/step - loss: 67021.1641
  Epoch 4/5
  29/29 [==============================] - 5s 188ms/step - loss: 65865.5547
  Epoch 5/5
  29/29 [==============================] - 5s 188ms/step - loss: 63510.2773
  
  >>> pred = model.predict(X['test'],
  >>>                      batch_size=100)
  >>> print(np.sort(pred))
  [-1.0868168  -0.46582496 -0.44715863 ...  3.2484274   3.3147712  3.326     ]
docstr_tok: ["Compute","scores","of","the","input","triples",".","Parameters","--","--","--","--","--","-","x",":","np.array",",","shape","(","n",",","3",")","or","str","or","GraphDataLoader","or","AbstractGraphPartitioner","Data","OR","Filename","of","the","data","file","OR","Data","Handle","to","be","used","for","training",".","batch_size",":","int","Batch","size","to","use","during","training",".","May","be","overridden","if","``","x","``","is","`","GraphDataLoader","`","or","`","AbstractGraphPartitioner","`","instance","verbose",":","bool","Verbosity","mode",".","callbacks",":","list","of","keras.callbacks.Callback","instances","List","of","callbacks","to","apply","during","evaluation",".","Returns","--","--","--","-","scores",":","np.array",",","shape","(","n",",",")","Score","of","the","input","triples",".","Example","--","--","--","-",">",">",">","from","ampligraph.latent_features","import","ScoringBasedEmbeddingModel",">",">",">","import","numpy","as","np",">",">",">","from","ampligraph.datasets","import","load_fb15k_237",">",">",">","X","=","load_fb15k_237","(",")",">",">",">","model","=","ScoringBasedEmbeddingModel","(","eta=5",",",">",">",">","k=300",",",">",">",">","scoring_type='ComplEx","'",",",">",">",">","seed=0",")",">",">",">","model.compile","(","optimizer='adam","'",",","loss='nll","'",")",">",">",">","model.fit","(","X","[","'train","'","]",",",">",">",">","batch_size=10000",",",">",">",">","epochs=5",")","Epoch","1\/5","29\/29","[","==============================","]","-","7s","228ms\/step","-","loss",":","67361.2734","Epoch","2\/5","29\/29","[","==============================","]","-","5s","184ms\/step","-","loss",":","67318.8203","Epoch","3\/5","29\/29","[","==============================","]","-","5s","187ms\/step","-","loss",":","67021.1641","Epoch","4\/5","29\/29","[","==============================","]","-","5s","188ms\/step","-","loss",":","65865.5547","Epoch","5\/5","29\/29","[","==============================","]","-","5s","188ms\/step","-","loss",":","63510.2773",">",">",">","pred","=","model.predict","(","X","[","'test","'","]",",",">",">",">","batch_size=100",")",">",">",">","print","(","np.sort","(","pred",")",")","[","-1.0868168","-0.46582496","-0.44715863","...","3.2484274","3.3147712","3.326","]"]
code: def predict(self, x, batch_size=32, verbose=0, callbacks=None):
      """
      Compute scores of the input triples.
  
      Parameters
      -----------
      x: np.array, shape (n, 3) or str or GraphDataLoader or AbstractGraphPartitioner
          Data OR Filename of the data file OR Data Handle to be used for training.
      batch_size: int
          Batch size to use during training.
          May be overridden if ``x`` is `GraphDataLoader` or `AbstractGraphPartitioner` instance
      verbose: bool
          Verbosity mode.
      callbacks: list of keras.callbacks.Callback instances
          List of callbacks to apply during evaluation.
  
      Returns
      -------
      scores: np.array, shape (n, )
          Score of the input triples.
  
      Example
      -------
      >>> from ampligraph.latent_features import ScoringBasedEmbeddingModel
      >>> import numpy as np
      >>> from ampligraph.datasets import load_fb15k_237
      >>> X = load_fb15k_237()
      >>> model = ScoringBasedEmbeddingModel(eta=5,
      >>>                                    k=300,
      >>>                                    scoring_type='ComplEx',
      >>>                                    seed=0)
      >>> model.compile(optimizer='adam', loss='nll')
      >>> model.fit(X['train'],
      >>>           batch_size=10000,
      >>>           epochs=5)
      Epoch 1/5
      29/29 [==============================] - 7s 228ms/step - loss: 67361.2734
      Epoch 2/5
      29/29 [==============================] - 5s 184ms/step - loss: 67318.8203
      Epoch 3/5
      29/29 [==============================] - 5s 187ms/step - loss: 67021.1641
      Epoch 4/5
      29/29 [==============================] - 5s 188ms/step - loss: 65865.5547
      Epoch 5/5
      29/29 [==============================] - 5s 188ms/step - loss: 63510.2773
  
      >>> pred = model.predict(X['test'],
      >>>                      batch_size=100)
      >>> print(np.sort(pred))
      [-1.0868168  -0.46582496 -0.44715863 ...  3.2484274   3.3147712  3.326     ]
  
      """
  
      self.data_handler_test = data_adapter.DataHandler(
          x,
          batch_size=batch_size,
          dataset_type="test",
          epochs=1,
          use_filter=False,
          use_indexer=self.data_indexer,
      )
  
      if not isinstance(callbacks, callbacks_module.CallbackList):
          callbacks = callbacks_module.CallbackList(
              callbacks,
              add_history=True,
              add_progbar=verbose != 0,
              model=self,
              verbose=verbose,
              epochs=1,
              steps=self.data_handler_test.inferred_steps,
          )
  
      predict_function = self.make_predict_function()
      callbacks.on_predict_begin()
      outputs = []
      for _, iterator in self.data_handler_test.enumerate_epochs():
          with self.data_handler_test.catch_stop_iteration():
              for step in self.data_handler_test.steps():
                  callbacks.on_predict_batch_begin(step)
                  batch_outputs = predict_function(iterator)
                  outputs.append(batch_outputs)
  
                  callbacks.on_predict_batch_end(
                      step, {"outputs": batch_outputs}
                  )
      callbacks.on_predict_end()
      return np.concatenate(outputs)
  
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 34 for calling the ScoringBasedEmbeddingModel obj's underlying member method code with example usage: obj.predict(x, batch_size, verbose, callbacks) and returns: np