<commit_before>from django.apps import apps
from django.conf import settings


def get_data_serializer(name):
    from bulbs.super_features.models import GUIDE_TO_HOMEPAGE, GUIDE_TO_ENTRY
    from bulbs.super_features.data_serializers import (GuideToChildSerializer,
                                                       GuideToParentSerializer)
    serializer = {
        GUIDE_TO_HOMEPAGE: GuideToParentSerializer,
        GUIDE_TO_ENTRY: GuideToChildSerializer
    }.get(name, None)
    if serializer is None:
        raise KeyError('The requested SuperFeature does not have a registered serializer')

    return serializer


def get_superfeature_model():
    from bulbs.super_features.models import BaseSuperFeature

    model_name = getattr(settings, "BULBS_SUPERFEATURE_MODEL", None)
    if model_name is None:
        return BaseSuperFeature
    return apps.get_model(model_name)


def get_superfeature_serializer():
    from bulbs.super_features.serializers import BaseSuperFeatureSerializer

    serializer = getattr(settings, "BULBS_SUPERFEATURE_SERIALIZER", None)
    if serializer is None:
        return BaseSuperFeatureSerializer
    return serializer


def get_superfeature_partial_serializer():
    from bulbs.super_features.serializers import BaseSuperFeaturePartialSerializer

    serializer = getattr(settings, "BULBS_SUPERFEATURE_PARTIAL_SERIALIZER", None)
    if serializer is None:
        return BaseSuperFeaturePartialSerializer
    return serializer


def get_superfeature_metadata():
    from bulbs.super_features.metadata import BaseSuperFeatureMetadata

    metadata = getattr(settings, "BULBS_SUPERFEATURE_METADATA", None)
    if metadata is None:
        return BaseSuperFeatureMetadata
    return metadata


def get_superfeature_choices():
    from bulbs.super_features.models import BASE_CHOICES

    configured_superfeatures = getattr(settings, "BULBS_CUSTOM_SUPERFEATURE_CHOICES", ())
    for sf in configured_superfeatures:
        if type(sf[0]) is not str or type(sf[1]) is not str:
            raise ValueError(<commit_msg>move imports to after if<commit_after>from django.apps import apps
from django.conf import settings


def get_data_serializer(name):
    from bulbs.super_features.models import GUIDE_TO_HOMEPAGE, GUIDE_TO_ENTRY
    from bulbs.super_features.data_serializers import (GuideToChildSerializer,
                                                       GuideToParentSerializer)
    serializer = {
        GUIDE_TO_HOMEPAGE: GuideToParentSerializer,
        GUIDE_TO_ENTRY: GuideToChildSerializer
    }.get(name, None)
    if serializer is None:
        raise KeyError('The requested SuperFeature does not have a registered serializer')

    return serializer


def get_superfeature_model():
    model_name = getattr(settings, "BULBS_SUPERFEATURE_MODEL", None)
    if model_name is None:
        from bulbs.super_features.models import BaseSuperFeature
        return BaseSuperFeature
    return apps.get_model(model_name)


def get_superfeature_serializer():
    serializer = getattr(settings, "BULBS_SUPERFEATURE_SERIALIZER", None)
    if serializer is None:
        from bulbs.super_features.serializers import BaseSuperFeatureSerializer
        return BaseSuperFeatureSerializer
    return serializer


def get_superfeature_partial_serializer():
    serializer = getattr(settings, "BULBS_SUPERFEATURE_PARTIAL_SERIALIZER", None)
    if serializer is None:
        from bulbs.super_features.serializers import BaseSuperFeaturePartialSerializer
        return BaseSuperFeaturePartialSerializer
    return serializer


def get_superfeature_metadata():
    metadata = getattr(settings, "BULBS_SUPERFEATURE_METADATA", None)
    if metadata is None:
        from bulbs.super_features.metadata import BaseSuperFeatureMetadata
        return BaseSuperFeatureMetadata
    return metadata


def get_superfeature_choices():
    from bulbs.super_features.models import BASE_CHOICES

    configured_superfeatures = getattr(settings, "BULBS_CUSTOM_SUPERFEATURE_CHOICES", ())
    for sf in configured_superfeatures:
        if type(sf[0]) is not str or type(sf[1]) is not str:
            raise ValueError(
{'fraction_non_alphanumeric': 0.05353267422232939, 'fraction_numerical': 0.0009645526886906198, 'mean_word_length': 3.9088757396449703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2335441', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1125, 'n_words': 283}