Hugging Face
Models
Datasets
Spaces
Community
Docs
Enterprise
Pricing
Log In
Sign Up
Spaces:
bartduis
/
rayst3r
like
0
Running
on
Zero
App
Files
Files
Community
Fetching metadata from the HF Docker repository...
9e5ce3d
rayst3r
/
utils
/
collate.py
bartduis
init
70d1188
3 months ago
raw
Copy download link
history
blame
Safe
213 Bytes
import
torch
def
collate
(
batch
):
if
isinstance
(batch[
0
],
dict
):
return
{k: collate([d[k]
for
d
in
batch])
for
k
in
batch[
0
].keys()}
else
:
return
torch.stack([torch.stack(t)
for
t
in
batch])