extract_representation_cpu refactored