<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def name_from_class(cls, measurement_class):
 """For a given measurement class, return its generic name. The given class is expected to have a ``name`` attribute, otherwise this function will raise an execption. The point of using this method instead of just trying to grab that attribute in the application is to cache measurement name to class mappings for future use. Returns: the generic OpenXC name for a measurement class. Raise: UnrecognizedMeasurementError: if the class does not have a valid generic name """

        if not getattr(cls, '_measurements_initialized', False):
            cls._measurement_map = dict((m.name, m) for m in all_measurements())
            cls._measurements_initialized = True

        try:
            name = getattr(measurement_class, 'name')
        except AttributeError:
            raise UnrecognizedMeasurementError("No 'name' attribute in %s" %
                    measurement_class)
        else:
            cls._measurement_map[name] = measurement_class
            return name