def _import_targets(
    import_request: LaunchDarklyImportRequest,
    ld_flag_config: ld_types.FeatureFlagConfig,
    feature: Feature,
    environment: Environment,
    segments_by_ld_key: dict[str, Segment],
    mv_feature_options_by_variation: dict[str, MultivariateFeatureOption],
) -> None:
    """
    Import the individual targeting rules for the given Launch Darkly's feature flag.

    :param ld_flag_config: the feature flag config from Launch Darkly.
    :param feature: the feature to target for identities.
    :param environment: the environment to target for identities.
    :param mv_feature_options_by_variation: a mapping from variation index to MultivariateFeatureOption if the
    flag is multivariate.
    """
    if "targets" in ld_flag_config:
        # Identifiers are grouped by their variation index. So each target has the same variation index.
        for target in ld_flag_config["targets"]:
            # Create a segment override for those identities. This is a work-around to support individual
            # targeting in local evaluation mode.
            # TODO: Remove this when https://github.com/Flagsmith/flagsmith/issues/3132 is resolved.
            feature_states = _create_feature_segment_from_clauses(
                import_request=import_request,
                clauses=[
                    {
                        "attribute": "key",
                        "op": "in",
                        "values": target["values"],
                        "negate": False,
                    }
                ],
                project=feature.project,
                feature=feature,
                environment=environment,
                segments_by_ld_key=segments_by_ld_key,
                rule_name=f"individual-targeting-variation-{target['variation']}",
            )

            _set_imported_mv_feature_state_values(
                variation_idx=str(target["variation"]),
                rollout=None,
                feature_states=feature_states,
                mv_feature_options_by_variation=mv_feature_options_by_variation,
            )

            # Create individual identity targets.
            for identifier in target["values"]:
                identity, _ = Identity.objects.get_or_create(
                    identifier=identifier,
                    environment=environment,
                )
                identity.update_traits(
                    [
                        {
                            "trait_key": "key",
                            "trait_value": identifier,  # type: ignore[typeddict-item]
                        }
                    ]
                )

                # Set identity overrides.
                if len(mv_feature_options_by_variation) == 0:
                    FeatureState.objects.update_or_create(
                        feature=feature,
                        feature_segment=None,
                        environment=environment,
                        identity=identity,
                        defaults={"enabled": target["variation"] == 0},
                    )
                else:
                    feature_state, _ = FeatureState.objects.update_or_create(
                        feature=feature,
                        feature_segment=None,
                        environment=environment,
                        identity=identity,
                        defaults={"enabled": True},
                    )

                    mv_feature_option = mv_feature_options_by_variation[
                        str(target["variation"])
                    ]
                    MultivariateFeatureStateValue.objects.update_or_create(
                        feature_state=feature_state,
                        multivariate_feature_option=mv_feature_option,
                        defaults={
                            "percentage_allocation": 100,
                        },
                    )

    if "contextTargets" in ld_flag_config and len(ld_flag_config["contextTargets"]) > 0:
        if (
            sum(
                [
                    len(context_target["values"])
                    for context_target in ld_flag_config["contextTargets"]
                ]
            )
            > 0
        ):
            _log_error(
                import_request=import_request,
                error_message=f"Context targets are not supported, skipping context targets for feature"
                f" {feature.name} in environment {environment.name}",
            )

    Import the individual targeting rules for the given Launch Darkly's feature flag.

    :param ld_flag_config: the feature flag config from Launch Darkly.
    :param feature: the feature to target for identities.
    :param environment: the environment to target for identities.
    :param mv_feature_options_by_variation: a mapping from variation index to MultivariateFeatureOption if the
    flag is multivariate.
    
api/integrations/launch_darkly/services.py