code: def embedding_to_matrix(
      embedding: Dict[str, np.array],
      token_index: Dict[str, int],
      embedding_dim: int,
  ) -> np.array:
      """
      Converts an embedding dictionary into a weights matrix used to initialize an embedding layer.
      It ensures that all tokens in the token_index dictionare are mapped to a row, even those that are
      not contained in the provided embedding dictionary. Unknown tokens are initialized with a random
      vector with entries between -1 and 1.
  
      Args:
          embedding: dictionary mapping tokens to embedding vectors
          token_index: dictionary mapping tokens to indices that are fed into the embedding layer
          embedding_dim: size of the embedding vectors
  
      Returns: embedding weights as numpy array
      """
      np.random.seed(42)
      embedding_matrix = (
          2.0 * np.random.rand(len(token_index) + 1, embedding_dim)
          - 1.0
      )
      for token, index in token_index.items():
          embedding_vec = embedding.get(token)
          if embedding_vec is not None:
              embedding_matrix[index] = embedding_vec
      return embedding_matrix
  
label_desc: Use image node_id 2 for calling a global function with example usage: embedding_to_matrix(embedding, token_index, embedding_dim) and returns: embedding_matrix