## JIT Recompilation Rules (MUST follow)

When writing tests for this function, you MUST obey these rules to avoid `torch.compile` / JIT recompilations:

1. **One canonical shape per parameter across ALL tests.** Pick a single shape (e.g. `(4,)` for 1-D, `(4, 3)` for 2-D) and reuse it in every test function. Do NOT use different shapes in different tests.
2. **Use `torch.float32` everywhere.** No `int32`, `int64`, `float64`, or mixed dtypes. Every tensor must be `dtype=torch.float32`.
3. **No `None` inputs.** Never pass `None` where a tensor is expected — `torch.compile` will trace it and crash.
4. **No rank mixing.** If the function takes a 1-D tensor, every test must pass a 1-D tensor. Never mix scalar, 1-D, and 2-D tensors across tests.
5. **Isolate edge cases.** If you must test empty tensors or unusual shapes, put them all in ONE dedicated `test_edge_cases()` function.
