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: Similar to keras lib, this function returns the handle to test step function.
  
  It processes one batch of data by iterating over the dataset iterator and computes the test metrics.
  
  Returns
  -------
  out: Function handle
        Handle to the test step function.
docstr_tok: ["Similar","to","keras","lib",",","this","function","returns","the","handle","to","test","step","function",".","It","processes","one","batch","of","data","by","iterating","over","the","dataset","iterator","and","computes","the","test","metrics",".","Returns","--","--","--","-","out",":","Function","handle","Handle","to","the","test","step","function","."]
code: def make_test_function(self):
      """Similar to keras lib, this function returns the handle to test step function.
  
      It processes one batch of data by iterating over the dataset iterator and computes the test metrics.
  
      Returns
      -------
      out: Function handle
            Handle to the test step function.
      """
  
      # if self.test_function is not None:
      #    return self.test_function
  
      def test_function(iterator):
          # total number of parts in which to split the embedding matrix
          # (default 1, i.e., use full matrix as it is)
          number_of_parts = 1
  
          # if it is partitioned training
          if self.is_partitioned_training:
              # split the emb matrix based on number of buckets
              number_of_parts = self.partitioner_k
  
          data = next(iterator)
          if self.use_filter:
              inputs, filters = data[0], data[1]
          else:
              if self.data_shape > 3:
                  inputs, filters = data[
                      0
                  ], tf.RaggedTensor.from_row_lengths([], [])
              else:
                  (
                      inputs,
                      filters,
                  ) = data, tf.RaggedTensor.from_row_lengths([], [])
  
          # compute the output shape based on the type of corruptions to be
          # used
          output_shape = 0
          if "s" in self.corrupt_side:
              output_shape += 1
  
          if "o" in self.corrupt_side:
              output_shape += 1
  
          # create an array to store the ranks based on output shape
          overall_rank = tf.zeros(
              (output_shape, tf.shape(inputs)[0]), dtype=np.int32
          )
  
          if self.is_partitioned_training:
              inputs = self.process_model_inputs_for_test(inputs)
  
          # run the loop based on number of parts in which the original emb
          # matrix was generated
          for j in range(number_of_parts):
              # get the embedding matrix along with entity ids of first and
              # last row of emb matrix
              (
                  emb_mat,
                  start_ent_id,
                  end_ent_id,
              ) = self.get_emb_matrix_test(j, number_of_parts)
              # compute the rank
              ranks = self._get_ranks(
                  inputs,
                  emb_mat,
                  start_ent_id,
                  end_ent_id,
                  filters,
                  self.mapping_dict,
                  self.corrupt_side,
                  self.ranking_strategy,
              )
              # store it in the output
              for i in tf.range(output_shape):
                  overall_rank = tf.tensor_scatter_nd_add(
                      overall_rank, [[i]], [ranks[i, :]]
                  )
  
          overall_rank = tf.transpose(
              tf.reshape(overall_rank, (output_shape, -1))
          )
          # if corruption type is s+o then add s and o ranks and return the
          # added ranks
          if self.corrupt_side == "s+o":
              # add the subject and object ranks
              overall_rank = tf.reduce_sum(overall_rank, 1)
              # return the added ranks
              return tf.reshape(overall_rank, (-1, 1))
  
          return overall_rank
  
      if not self.run_eagerly and not self.is_partitioned_training:
          test_function = def_function.function(
              test_function, experimental_relax_shapes=True
          )
  
      self.test_function = test_function
  
      return self.test_function
  
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 28 for calling the ScoringBasedEmbeddingModel obj's underlying member method code with example usage: obj.make_test_function() and returns: self, overall_rank, tf