BUG: AttributeError: 'function' object has no attribute 'im_func'