rllm.utils

Utils

download_url

Download the content of a URL to a specific folder.

download_google_url

Download the content of a Google Drive file to a specific folder.

extract_zip

Extract a zip archive to a specific folder.

sparse_mx_to_torch_sparse_tensor

Convert a scipy sparse matrix to a torch.sparse.Tensor.

is_torch_sparse_tensor

Return True if the input is a torch.sparse.Tensor.

get_indices

Get indices of non-zero elements from an adjacency matrix.

is_undirected

Check if the given adjacency matrix represents an undirected graph.

to_undirected

Convert the given adjacency matrix to an undirected graph representation by adding reverse edges.

adj_to_edge_index

Convert a sparse adjacency matrix to an edge index tensor.

seg_sum

Compute the sum of elements in data for each segment specified by segment_ids.

seg_softmax

Compute the segment-wise softmax scores of elements in data.

sort_edge_index

Sort the edge index.

index_to_ptr

Convert a sorted index tensor to a CSR/CSC pointer tensor.

lexsort

Perform an indirect stable sort using a sequence of keys.

remap_keys

Remap the keys of the input dictionary using a mapping.

CastMixin

Support cast init from tuple or dict input.