def METHOD_NAME(cls):
    n = 0
    for x in gc.get_objects():
        try:
            if isinstance(x, cls):
                n += 1
        except (ReferenceError, AttributeError):
            pass
    return n