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 the embeddings of entities or relations.
  
  .. Note ::
  
      Use :meth:`ampligraph.utils.create_tensorboard_visualizations` to visualize the embeddings with TensorBoard.
  
  Parameters
  ----------
  entities : array-like, shape=(n)
      The entities (or relations) of interest. Element of the vector must be the original string literals, and
      not internal IDs.
  embedding_type : str
      If `'e'` is passed, ``entities`` argument will be considered as a list of knowledge graph entities
      (i.e., nodes). If set to `'r'`, ``entities`` will be treated as relations instead.
  Returns
  -------
  embeddings : ndarray, shape (n, k)
      An array of `k`-dimensional embeddings.
  
  Example
  -------
  >>> from ampligraph.latent_features import ScoringBasedEmbeddingModel
  >>> 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,
  >>>           verbose=False)
  >>> model.get_embeddings(['/m/027rn', '/m/06v8s0'], 'e')
  array([[ 0.04482496  0.11973907  0.01117733 ... -0.13391922  0.11103553  -0.08132861]
   [-0.10158381  0.08108605 -0.07608676 ...  0.0591407  0.02791426  0.07559016]], dtype=float32)
docstr_tok: ["Get","the","embeddings","of","entities","or","relations",".","..","Note",":",":","Use",":","meth",":","`","ampligraph.utils.create_tensorboard_visualizations","`","to","visualize","the","embeddings","with","TensorBoard",".","Parameters","--","--","--","--","--","entities",":","array-like",",","shape=","(","n",")","The","entities","(","or","relations",")","of","interest",".","Element","of","the","vector","must","be","the","original","string","literals",",","and","not","internal","IDs",".","embedding_type",":","str","If","`","'","e","'","`","is","passed",",","``","entities","``","argument","will","be","considered","as","a","list","of","knowledge","graph","entities","(","i.e.",",","nodes",")",".","If","set","to","`","'","r","'","`",",","``","entities","``","will","be","treated","as","relations","instead",".","Returns","--","--","--","-","embeddings",":","ndarray",",","shape","(","n",",","k",")","An","array","of","`","k","`","-dimensional","embeddings",".","Example","--","--","--","-",">",">",">","from","ampligraph.latent_features","import","ScoringBasedEmbeddingModel",">",">",">","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",",",">",">",">","verbose=False",")",">",">",">","model.get_embeddings","(","[","'\/m\/027rn","'",",","'\/m\/06v8s0","'","]",",","'","e","'",")","array","(","[","[","0.04482496","0.11973907","0.01117733","...","-0.13391922","0.11103553","-0.08132861","]","[","-0.10158381","0.08108605","-0.07608676","...","0.0591407","0.02791426","0.07559016","]","]",",","dtype=float32",")"]
code: def get_embeddings(self, entities, embedding_type="e"):
      """Get the embeddings of entities or relations.
  
      .. Note ::
  
          Use :meth:`ampligraph.utils.create_tensorboard_visualizations` to visualize the embeddings with TensorBoard.
  
      Parameters
      ----------
      entities : array-like, shape=(n)
          The entities (or relations) of interest. Element of the vector must be the original string literals, and
          not internal IDs.
      embedding_type : str
          If `'e'` is passed, ``entities`` argument will be considered as a list of knowledge graph entities
          (i.e., nodes). If set to `'r'`, ``entities`` will be treated as relations instead.
      Returns
      -------
      embeddings : ndarray, shape (n, k)
          An array of `k`-dimensional embeddings.
  
      Example
      -------
      >>> from ampligraph.latent_features import ScoringBasedEmbeddingModel
      >>> 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,
      >>>           verbose=False)
      >>> model.get_embeddings(['/m/027rn', '/m/06v8s0'], 'e')
      array([[ 0.04482496  0.11973907  0.01117733 ... -0.13391922  0.11103553  -0.08132861]
       [-0.10158381  0.08108605 -0.07608676 ...  0.0591407  0.02791426  0.07559016]], dtype=float32)
      """
  
      if embedding_type == "e":
          lookup_concept = self.data_indexer.get_indexes(entities, "e")
          if self.is_partitioned_training:
              emb_out = []
              with shelve.open(
                  self.partitioner_metadata["ent_map_fname"]
              ) as ent_emb:
                  for ent_id in lookup_concept:
                      emb_out.append(ent_emb[str(ent_id)])
          else:
              return tf.nn.embedding_lookup(
                  self.encoding_layer.ent_emb, lookup_concept
              ).numpy()
      elif embedding_type == "r":
          lookup_concept = self.data_indexer.get_indexes(entities, "r")
          if self.is_partitioned_training:
              emb_out = []
              with shelve.open(
                  self.partitioner_metadata["rel_map_fname"]
              ) as rel_emb:
                  for rel_id in lookup_concept:
                      emb_out.append(rel_emb[str(rel_id)])
          else:
              return tf.nn.embedding_lookup(
                  self.encoding_layer.rel_emb, lookup_concept
              ).numpy()
      else:
          msg = "Invalid entity type: {}".format(embedding_type)
          raise ValueError(msg)
  
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 38 for calling the ScoringBasedEmbeddingModel obj's underlying member method code with example usage: obj.get_embeddings(entities, embedding_type) and returns: tf, tf