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: Evaluate the inputs against corruptions and return ranks.
  
  Parameters
  ----------
  inputs: array-like, shape (n, 3)
      Batch of input triples.
  ent_embs: array-like, shape (m, k)
      Slice of embedding matrix (corruptions).
  start_id: int
      Original id of the first row of embedding matrix (used during partitioned approach).
  end_id: int
      Original id of the last row of embedding matrix (used during partitioned approach).
  filters: list of lists
      Size of list is either 1 or 2 depending on ``corrupt_side``.
      Size of the internal list is equal to the size of the input triples.
      Each list contains an array of filters (i.e., True Positives) related to the specified side of the
      corresponding input triples.
  corrupt_side: str
      Which side to corrupt during evaluation.
  ranking_strategy: str
      Indicates how to break ties (default: `worst`, i.e., assigns the worst rank to the test triple).
      Can be one of the three types `"best"`, `"middle"`, `"worst"`.
  
  Returns
  -------
  rank: tf.Tensor, shape (n, num of sides being corrupted)
      Ranking against subject corruptions and object corruptions
      (corruptions defined by `ent_embs` matrix).
docstr_tok: ["Evaluate","the","inputs","against","corruptions","and","return","ranks",".","Parameters","--","--","--","--","--","inputs",":","array-like",",","shape","(","n",",","3",")","Batch","of","input","triples",".","ent_embs",":","array-like",",","shape","(","m",",","k",")","Slice","of","embedding","matrix","(","corruptions",")",".","start_id",":","int","Original","id","of","the","first","row","of","embedding","matrix","(","used","during","partitioned","approach",")",".","end_id",":","int","Original","id","of","the","last","row","of","embedding","matrix","(","used","during","partitioned","approach",")",".","filters",":","list","of","lists","Size","of","list","is","either","1","or","2","depending","on","``","corrupt_side","``",".","Size","of","the","internal","list","is","equal","to","the","size","of","the","input","triples",".","Each","list","contains","an","array","of","filters","(","i.e.",",","True","Positives",")","related","to","the","specified","side","of","the","corresponding","input","triples",".","corrupt_side",":","str","Which","side","to","corrupt","during","evaluation",".","ranking_strategy",":","str","Indicates","how","to","break","ties","(","default",":","`","worst","`",",","i.e.",",","assigns","the","worst","rank","to","the","test","triple",")",".","Can","be","one","of","the","three","types","`","``","best","''","`",",","`","``","middle","''","`",",","`","``","worst","''","`",".","Returns","--","--","--","-","rank",":","tf.Tensor",",","shape","(","n",",","num","of","sides","being","corrupted",")","Ranking","against","subject","corruptions","and","object","corruptions","(","corruptions","defined","by","`","ent_embs","`","matrix",")","."]
code: def _get_ranks(
      self,
      inputs,
      ent_embs,
      start_id,
      end_id,
      filters,
      mapping_dict,
      corrupt_side="s,o",
      ranking_strategy="worst",
  ):
      """
      Evaluate the inputs against corruptions and return ranks.
  
      Parameters
      ----------
      inputs: array-like, shape (n, 3)
          Batch of input triples.
      ent_embs: array-like, shape (m, k)
          Slice of embedding matrix (corruptions).
      start_id: int
          Original id of the first row of embedding matrix (used during partitioned approach).
      end_id: int
          Original id of the last row of embedding matrix (used during partitioned approach).
      filters: list of lists
          Size of list is either 1 or 2 depending on ``corrupt_side``.
          Size of the internal list is equal to the size of the input triples.
          Each list contains an array of filters (i.e., True Positives) related to the specified side of the
          corresponding input triples.
      corrupt_side: str
          Which side to corrupt during evaluation.
      ranking_strategy: str
          Indicates how to break ties (default: `worst`, i.e., assigns the worst rank to the test triple).
          Can be one of the three types `"best"`, `"middle"`, `"worst"`.
  
      Returns
      -------
      rank: tf.Tensor, shape (n, num of sides being corrupted)
          Ranking against subject corruptions and object corruptions
          (corruptions defined by `ent_embs` matrix).
      """
      if not self.is_partitioned_training:
          inputs = [
              tf.nn.embedding_lookup(
                  self.encoding_layer.ent_emb, inputs[:, 0]
              ),
              tf.nn.embedding_lookup(
                  self.encoding_layer.rel_emb, inputs[:, 1]
              ),
              tf.nn.embedding_lookup(
                  self.encoding_layer.ent_emb, inputs[:, 2]
              ),
          ]
  
      return self.scoring_layer.get_ranks(
          inputs,
          ent_embs,
          start_id,
          end_id,
          filters,
          mapping_dict,
          corrupt_side,
          ranking_strategy,
      )
  
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 8 for calling the ScoringBasedEmbeddingModel obj's underlying member method code with example usage: obj._get_ranks(inputs, ent_embs, start_id, end_id, filters, mapping_dict, corrupt_side, ranking_strategy) and returns: self