code: def _read_embeddings_from_hdf5(
      embeddings_filename, embedding_dim, vocab, namespace="tokens"
  ):
      """
      Reads from a hdf5 formatted file. The embedding matrix is assumed to
      be keyed by 'embedding' and of size ``(num_tokens, embedding_dim)``.
      """
      with h5py.File(embeddings_filename, "r") as fin:
          embeddings = fin["embedding"][...]
  
      if list(embeddings.shape) != [
          vocab.get_vocab_size(namespace),
          embedding_dim,
      ]:
          raise ConfigurationError(
              "Read shape {0} embeddings from the file, but expected {1}".format(
                  list(embeddings.shape),
                  [vocab.get_vocab_size(namespace), embedding_dim],
              )
          )
  
      return torch.FloatTensor(embeddings)
  
imports: from __future__ import with_statement
  from __future__ import absolute_import
  import io
  import tarfile
  import zipfile
  import bz2
  import gzip
  import re
  import logging
  import warnings
  import itertools
  import numpy
  import torch
  from torch.nn.functional import embedding
  from allennlp.common import Params, Tqdm
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.file_utils import get_file_extension, cached_path
  from allennlp.data import Vocabulary
  from allennlp.modules.token_embedders.token_embedder import TokenEmbedder
  from allennlp.modules.time_distributed import TimeDistributed
label_desc: Use image node_id 3 for calling a global function with example usage: _read_embeddings_from_hdf5(embeddings_filename, embedding_dim, vocab, namespace) and returns: torch