def make_residual_projection_to_final_residual_grad_scalar_deriver_factory_for_activation_location_type(
    activation_location_type: ActivationLocationType,
    use_existing_backward_pass_for_final_residual_grad: bool,
) -> Callable[[DstConfig], ScalarDeriver]:
    """this is for DerivedScalarType's 1:1 with a ActivationLocationType, which can be generated from just the ActivationLocationType
    and no additional information"""

    if use_existing_backward_pass_for_final_residual_grad:
        dst = _residual_projection_to_final_residual_grad_dst_by_activation_location_type[
            activation_location_type
        ]
    else:
        dst = (
            _residual_projection_to_final_activation_residual_grad_dst_by_activation_location_type[
                activation_location_type
            ]
        )

    assert activation_location_type.shape_spec_per_token_sequence == (
        Dimension.SEQUENCE_TOKENS,
        Dimension.RESIDUAL_STREAM_CHANNELS,
    ), f"Residual norm only defined for residual stream activations, not {activation_location_type=} with shape {activation_location_type.shape_spec_per_token_sequence=}"

    def make_scalar_deriver_fn(
        dst_config: DstConfig,
    ) -> ScalarDeriver:
        residual_scalar_deriver = make_scalar_deriver_factory_for_activation_location_type(
            activation_location_type
        )(dst_config)

        return convert_scalar_deriver_to_write_to_final_residual_grad(
            scalar_deriver=residual_scalar_deriver,
            use_existing_backward_pass_for_final_residual_grad=use_existing_backward_pass_for_final_residual_grad,
            output_dst=dst,
        )

    return make_scalar_deriver_fn
this is for DerivedScalarType's 1:1 with a ActivationLocationType, which can be generated from just the ActivationLocationType
    and no additional information
neuron_explainer/activations/derived_scalars/residual.py