segment.py added a try-except to import reduce from functools in python 3