def METHOD_NAME(num_sub_states, ndim_states, timestamp):
    """Create a random number of composite detections, each with `num_sub_states`
    sub-detections.
    """
    measurement_models = [
        create_measurement_model(True, ndim_states[0]),
        create_measurement_model(True, ndim_states[1]),
        create_measurement_model(True, ndim_states[2]),
        create_measurement_model(True, ndim_states[3]),
        create_measurement_model(False, ndim_states[4])
    ]
    measurements = set()
    for _ in range(np.random.randint(3, 6)):
        sub_measurements = [
            Detection(
                state_vector=create_state(True, False, ndim_states[0], timestamp).state_vector,
                timestamp=timestamp,
                measurement_model=measurement_models[0]),
            Detection(
                state_vector=create_state(True, False, ndim_states[1], timestamp).state_vector,
                timestamp=timestamp,
                measurement_model=measurement_models[1]),
            Detection(
                state_vector=create_state(True, False, ndim_states[2], timestamp).state_vector,
                timestamp=timestamp,
                measurement_model=measurement_models[2]),
            Detection(
                state_vector=create_state(True, False, ndim_states[3], timestamp).state_vector,
                timestamp=timestamp,
                measurement_model=measurement_models[3]),
            CategoricalDetection(
                state_vector=create_state(False, False, ndim_states[4], timestamp).state_vector,
                timestamp=timestamp,
                measurement_model=measurement_models[4])
        ]
        measurements.add(CompositeDetection(sub_measurements[:num_sub_states]))
    measurement1 = measurements.pop()
    # Create a measurement with reversed mapping
    sub_states = list(np.flip(measurement1.sub_states))
    mapping = list(np.flip(measurement1.mapping))
    reversed_measurement = CompositeDetection(sub_states, mapping=mapping)
    measurements.add(reversed_measurement)
    if num_sub_states > 1:
        # Create a measurement without one sub-state element
        measurement2 = measurements.pop()
        missed_index = np.random.randint(num_sub_states)
        sub_states = measurement2.sub_states[:missed_index] + measurement2.sub_states[
                                                              missed_index + 1:]
        mapping = measurement2.mapping[:missed_index] + measurement2.mapping[missed_index + 1:]
        incomplete_measurement = CompositeDetection(sub_states, mapping=mapping)
        measurements.add(incomplete_measurement)
    return measurements