Savez_compressed obj to file_name.

def savez_two_column(matrix, row_offset, file_name, append=False):
  """Savez_compressed obj to file_name."""
  logging.info("Saving obj to file in two column .npz format %s.", file_name)
  tc = []
  for u, items in enumerate(matrix):
    user = row_offset + u
    for item in items:
      tc.append([user, item])
  
  np.savez_compressed(file_name, np.asarray(tc))
  logging.info("Done saving to file %s.", file_name)