def get_preactivation_tensors(layers):
    """Get all valid layers for computing saturation."""
    dense_outputs = []
    for layer in layers:
        if 'dense' in layer.name:
            if '_input' in layer.name:
                continue
            if hasattr(layer, 'activation'
                ) and layer.activation.__name__ != 'linear':
                preactivation_tensor = layer.output.op.inputs[0]
            else:
                preactivation_tensor = layer.output
            dense_outputs.append(preactivation_tensor)
    return dense_outputs
