<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def vectorize_range(values):
 """ This function is for url encoding. Takes a value or a tuple or list of tuples and returns a single result, tuples are joined by "," if necessary, elements in tuple are joined by '_' """

    if isinstance(values, tuple):
        return '_'.join(str(i) for i in values)
    if isinstance(values, list):
        if not all([isinstance(item, tuple) for item in values]):
            raise TypeError('Items in the list must be tuples')
        return ','.join('_'.join(str(i) for i in v) for v in values)
    return str(values)