(x, patch_size)
| 212 | |
| 213 | |
| 214 | def unpatchify(x, patch_size): |
| 215 | if patch_size == 1: |
| 216 | return x |
| 217 | if x.dim() == 4: |
| 218 | x = rearrange(x, "b (c r q) h w -> b c (h q) (w r)", q=patch_size, r=patch_size) |
| 219 | elif x.dim() == 5: |
| 220 | x = rearrange(x, |
| 221 | "b (c r q) f h w -> b c f (h q) (w r)", |
| 222 | q=patch_size, |
| 223 | r=patch_size) |
| 224 | return x |
| 225 | |
| 226 | |
| 227 | class Resample38(Resample): |