code: def test_set_initializer():
      model = ScoringBasedEmbeddingModel(k=3, eta=1)
      model.compile(
          optimizer="adam",
          loss="pairwise",
          entity_relation_initializer=[
              tf.constant_initializer(
                  [[0, 1, 2], [0, 1, 2], [0, 1, 2]]
              ),
              tf.constant_initializer([[10, 11, 12], [10, 11, 12]]),
          ],
      )
  
      model.encoding_layer.max_ent_size = 3
      model.encoding_layer.max_rel_size = 2
      model.encoding_layer.build((10, 10))
      assert (
          model.encoding_layer.ent_emb.numpy()
          == np.array(
              [[0, 1, 2], [0, 1, 2], [0, 1, 2]], dtype=np.float32
          )
      ).all(), "EmbeddingLookupLayer (initializer): Entity embeddings dont match!"
  
      assert (
          model.encoding_layer.rel_emb.numpy()
          == np.array([[10, 11, 12], [10, 11, 12]], dtype=np.float32)
      ).all(), "EmbeddingLookupLayer (initializer): Relation embeddings dont match!"
  
      model = ScoringBasedEmbeddingModel(k=3, eta=1)
  
      model.compile(
          optimizer="adam",
          loss="pairwise",
          entity_relation_initializer=tf.constant_initializer(
              [[0, 1, 2], [0, 1, 2], [0, 1, 2]]
          ),
      )
      model.encoding_layer.max_ent_size = 3
      model.encoding_layer.max_rel_size = 3
      model.encoding_layer.build((10, 10))
  
      assert (
          model.encoding_layer.ent_emb.numpy()
          == np.array(
              [[0, 1, 2], [0, 1, 2], [0, 1, 2]], dtype=np.float32
          )
      ).all(), "EmbeddingLookupLayer (initializer): Entity embeddings dont match!"
  
      assert (
          model.encoding_layer.rel_emb.numpy()
          == np.array(
              [[0, 1, 2], [0, 1, 2], [0, 1, 2]], dtype=np.float32
          )
      ).all(), "EmbeddingLookupLayer (initializer): Relation embeddings dont match!"
  
      with pytest.raises(
          AssertionError,
          match="Incorrect length for initializer. Assumed 2 got 3",
      ):
          model = ScoringBasedEmbeddingModel(k=3, eta=1)
          model.compile(
              optimizer="adam",
              loss="pairwise",
              entity_relation_initializer=[
                  tf.constant_initializer(
                      [[0, 1, 2], [0, 1, 2], [0, 1, 2]]
                  ),
                  tf.constant_initializer([[10, 11, 12], [10, 11, 12]]),
                  tf.constant_initializer([[10, 11, 12], [10, 11, 12]]),
              ],
          )
  
          model.encoding_layer.max_ent_size = 3
          model.encoding_layer.max_rel_size = 2
          model.encoding_layer.build((10, 10))
  
file_path: AmpliGraph/tests/ampligraph/latent_features/layers/encoding/test_EmbeddingLookupLayer.py
imports: from ampligraph.latent_features.layers.encoding import EmbeddingLookupLayer
  from ampligraph.latent_features import ScoringBasedEmbeddingModel
  import pytest
  import tensorflow
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: test_set_initializer() without return types