<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def allinstances(cls):
 """Return all instances that inherit from JB_Gui :returns: all instances that inherit from JB_Gui :rtype: list :raises: None """

        JB_Gui._allinstances = weakref.WeakSet([i for i in cls._allinstances if shiboken.isValid(i)])
        return list(cls._allinstances)