<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_hyperedge_weight_matrix(H, hyperedge_ids_to_indices):
 """Creates the diagonal matrix W of hyperedge weights as a sparse matrix. :param H: the hypergraph to find the weights. :param hyperedge_weights: the mapping from the indices of hyperedge IDs to the corresponding hyperedge weights. :returns: sparse.csc_matrix -- the diagonal edge weight matrix as a sparse matrix. """

    # Combined 2 methods into 1; this could be written better
    hyperedge_weights = {}
    for hyperedge_id in H.hyperedge_id_iterator():
        hyperedge_weights.update({hyperedge_ids_to_indices[hyperedge_id]:
                                 H.get_hyperedge_weight(hyperedge_id)})

    hyperedge_weight_vector = []
    for i in range(len(hyperedge_weights.keys())):
        hyperedge_weight_vector.append(hyperedge_weights.get(i))

    return sparse.diags([hyperedge_weight_vector], [0])