Fix loading a metric with internal import
After refactoring the module factory (#2986), a bug was introduced when loading metrics with internal imports.

This PR adds a new test case and fixes this bug.

Fix #3076.

CC: @sgugger @merveenoyan 