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: Get parameters for focusE.
  
  Parameters
  ----------
  dict_params: dict
      The following hyper-params can be passed:
  
      - "non_linearity": can assume of the following values `"linear"`, `"softplus"`, `"sigmoid"`, `"tanh"`.
      - "stop_epoch": specifies how long to decay (linearly) the structural influence hyper-parameter             from 1 until it reaches its original value.
      - "structural_wt": structural influence hyperparameter [0, 1] that modulates the influence of graph             topology.
  
      If the respective key is missing: ``non_linearity="linear"``, ``stop_epoch=251`` and ``structural_wt=0.001``.
  
  Returns
  -------
  focusE_params : tuple
      A tuple containing three values: the non-linearity function (`str`), the `stop_epoch` (`int`) and the
      structure weight (`float`).
docstr_tok: ["Get","parameters","for","focusE",".","Parameters","--","--","--","--","--","dict_params",":","dict","The","following","hyper-params","can","be","passed",":","-","``","non_linearity","''",":","can","assume","of","the","following","values","`","``","linear","''","`",",","`","``","softplus","''","`",",","`","``","sigmoid","''","`",",","`","``","tanh","''","`",".","-","``","stop_epoch","''",":","specifies","how","long","to","decay","(","linearly",")","the","structural","influence","hyper-parameter","from","1","until","it","reaches","its","original","value",".","-","``","structural_wt","''",":","structural","influence","hyperparameter","[","0",",","1","]","that","modulates","the","influence","of","graph","topology",".","If","the","respective","key","is","missing",":","``","non_linearity=","''","linear","''","``",",","``","stop_epoch=251","``","and","``","structural_wt=0.001","``",".","Returns","--","--","--","-","focusE_params",":","tuple","A","tuple","containing","three","values",":","the","non-linearity","function","(","`","str","`",")",",","the","`","stop_epoch","`","(","`","int","`",")","and","the","structure","weight","(","`","float","`",")","."]
code: def get_focusE_params(self, dict_params={}):
      """Get parameters for focusE.
  
          Parameters
          ----------
          dict_params: dict
              The following hyper-params can be passed:
  
              - "non_linearity": can assume of the following values `"linear"`, `"softplus"`, `"sigmoid"`, `"tanh"`.
              - "stop_epoch": specifies how long to decay (linearly) the structural influence hyper-parameter \
              from 1 until it reaches its original value.
              - "structural_wt": structural influence hyperparameter [0, 1] that modulates the influence of graph \
              topology.
  
              If the respective key is missing: ``non_linearity="linear"``, ``stop_epoch=251`` and ``structural_wt=0.001``.
  
          Returns
          -------
          focusE_params : tuple
              A tuple containing three values: the non-linearity function (`str`), the `stop_epoch` (`int`) and the
              structure weight (`float`).
  
          """
      # Get the non-linearity function
      non_linearity = dict_params.get("non_linearity", "linear")
      if non_linearity == "linear":
          non_linearity = tf.identity
      elif non_linearity == "tanh":
          non_linearity = tf.tanh
      elif non_linearity == "sigmoid":
          non_linearity = tf.sigmoid
      elif non_linearity == "softplus":
  
          @tf.custom_gradient
          def custom_softplus(x):
              e = 9999 * tf.exp(x)
  
              def grad(dy):
                  return dy * (1 - 1 / (1 + e))
  
              return tf.math.log(1 + e), grad
  
          non_linearity = custom_softplus
  
      else:
          raise ValueError("Invalid focusE non-linearity")
  
      # Get the stop_epoch for the decay
      stop_epoch = dict_params.get("stop_epoch", 251)
      msg = "Invalid value for focusE stop_epoch: expected a value >=0 but got {}".format(
          stop_epoch
      )
      assert stop_epoch >= 0, msg
  
      # Get structural_wt
      structure_weight = dict_params.get("structural_wt", 0.001)
      assert (structure_weight <= 1) and (
          structure_weight >= 0
      ), "Invalid focusE 'structural_wt' passed! It has to belong to [0,1]."
  
      # if stop_epoch == 0, fixed structure weights is used
      if stop_epoch > 0:
          # linear decay of numeric values
          structure_weight = tf.maximum(
              1 - self.current_epoch / stop_epoch, 0.001
          )
  
      return non_linearity, stop_epoch, structure_weight
  
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 13 for calling the ScoringBasedEmbeddingModel obj's underlying member method code with example usage: obj.get_focusE_params(dict_params) and returns: non_linearity,  stop_epoch,  structure_weight, tf,  grad, unknown