code: def _hfd5_from_dataframe(data, track_info, outputfilename):
      # create a sparse matrix of all the users/plays
      plays = coo_matrix(
          (
              data["plays"].astype(np.float32),
              (
                  data["track"].cat.codes.copy(),
                  data["user"].cat.codes.copy(),
              ),
          )
      ).tocsr()
  
      with h5py.File(outputfilename, "w") as f:
          g = f.create_group("track_user_plays")
          g.create_dataset("data", data=plays.data)
          g.create_dataset("indptr", data=plays.indptr)
          g.create_dataset("indices", data=plays.indices)
  
          dt = h5py.special_dtype(vlen=str)
          dset = f.create_dataset("track", track_info.shape, dtype=dt)
          dset[:] = track_info
  
          user = list(data["user"].cat.categories)
          dset = f.create_dataset("user", (len(user),), dtype=dt)
          dset[:] = user
  
file_path: implicit/implicit/datasets/million_song_dataset.py
imports: import logging
  import os
  import time
  import h5py
  import numpy
  from scipy.sparse import coo_matrix, csr_matrix
  from tqdm.auto import tqdm
  from implicit.datasets import _download
label_desc: Use image node_id 5 for calling a global function with example usage: _hfd5_from_dataframe(data, track_info, outputfilename) without return types