def as_tuple(item, type=None, length=None):
    # Empty list if we get passed None
    if item is None:
        t = ()
    else:
        # Convert iterable to list...
        try:
            t = tuple(item)
        # ... or create a list of a single item
        except (__HOLE__, NotImplementedError):
            t = (item,) * (length or 1)
    if configuration["type_check"]:
        if length and not len(t) == length:
            raise ValueError("Tuple needs to be of length %d" % length)
        if type and not all(isinstance(i, type) for i in t):
            raise TypeError("Items need to be of type %s" % type)
    return t
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/as_tuple