def validate_output_indices(
    output_indices: list[int], model_num_blocks: int, depth: int
):
    """
    Validate the output indices are within the valid range of the model and the
    length of the output indices is equal to the depth of the encoder.
    """
    for output_index in output_indices:
        if output_index < -model_num_blocks or output_index >= model_num_blocks:
            raise ValueError(
                f"Output indices for feature extraction should be in range "
                f"[-{model_num_blocks}, {model_num_blocks}), because the model has {model_num_blocks} blocks, "
                f"got index = {output_index}."
            )

    Validate the output indices are within the valid range of the model and the
    length of the output indices is equal to the depth of the encoder.
    
segmentation_models_pytorch/encoders/timm_vit.py