<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collect_ansible_classes():
 """Run playbook and collect classes of ansible that are run."""

    def trace_calls(frame, event, arg):  # pylint: disable=W0613
        """Trace function calls to collect ansible classes.

        Trace functions and check if they have self as an arg. If so, get their class if the
        class belongs to ansible.
        """
        if event != 'call':
            return
        try:
            _locals = inspect.getargvalues(frame).locals
            if 'self' not in _locals:
                return
            _class = _locals['self'].__class__
            _class_repr = repr(_class)
            if 'ansible' not in _class_repr:
                return
            ANSIBLE_CLASSES[_class] = True
        except (AttributeError, TypeError):
            pass

    print "Gathering classes"
    sys.settrace(trace_calls)
    main()