ValentineKRAFTON's picture
initial commit
acd771b verified
# Originally from OpenCLIP (https://github.com/mlfoundations/open_clip)
import collections.abc
from itertools import repeat
def _ntuple(n):
def parse(x):
if isinstance(x, collections.abc.Iterable):
return x
return tuple(repeat(x, n))
return parse
to_2tuple = _ntuple(2)