def _parse_no_logprobs_completion_json(
    completion: str,
    tokens: Sequence[str],
) -> list[float]:
    """
    Parse a completion into a list of simulated activations. If the model did not faithfully
    reproduce the token sequence, return a list of 0s. If the model's activation for a token
    is not a number between 0 and 10 (inclusive), substitute 0.

    Args:
        completion: completion from the API
        tokens: list of tokens as strings in the sequence where the neuron is being simulated
    """
    zero_prediction: list[float] = [0.0] * len(tokens)

    try:
        completion_json: dict = json.loads(completion)
        if "activations" not in completion_json:
            logger.error(
                "The key 'activations' is not in the logprob free simulator response. Not a severe error, throw rate depends on how well the model can reproduce a particular JSON format."
            )
            return zero_prediction
        activations = completion_json["activations"]
        if len(activations) != len(tokens):
            return zero_prediction
        predicted_activations: list[float] = []
        # check that there is a token and activation value
        # no need to double check the token matches exactly
        for activation in activations:
            if "token" not in activation:
                predicted_activations.append(0)
                continue
            if "activation" not in activation:
                predicted_activations.append(0)
                continue
            # Ensure activation value is between 0-10 inclusive
            try:
                predicted_activation_float = float(activation["activation"])
                if (
                    predicted_activation_float < 0
                    or predicted_activation_float > MAX_NORMALIZED_ACTIVATION
                ):
                    predicted_activations.append(0.0)
                else:
                    predicted_activations.append(predicted_activation_float)
            except ValueError:
                predicted_activations.append(0)
            except TypeError:
                predicted_activations.append(0)
        logger.debug("predicted activations: %s", predicted_activations)
        return predicted_activations

    except json.JSONDecodeError:
        logger.error(
            "Error: the logprob free simulator response is not valid JSON. Not a severe error, throw rate depends on the model's ability to produce JSON."
        )
        return zero_prediction

    Parse a completion into a list of simulated activations. If the model did not faithfully
    reproduce the token sequence, return a list of 0s. If the model's activation for a token
    is not a number between 0 and 10 (inclusive), substitute 0.

    Args:
        completion: completion from the API
        tokens: list of tokens as strings in the sequence where the neuron is being simulated
    
neuron_explainer/explanations/simulator.py