<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def imported_classifiers_package(p: ecore.EPackage):
 """Determines which classifiers have to be imported into given package."""

        classes = {c for c in p.eClassifiers if isinstance(c, ecore.EClass)}

        references = itertools.chain(*(c.eAllReferences() for c in classes))
        references_types = (r.eType for r in references)
        imported = {c for c in references_types if getattr(c, 'ePackage', p) is not p}

        imported_dict = {}
        for classifier in imported:
            imported_dict.setdefault(classifier.ePackage, set()).add(classifier)

        return imported_dict