Fix PPFormulaNet training-loss double-shift (train against labels, not labels[..., 1:])
Author: OmkumarSolanki
Pull request: yes

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=46903)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=46903)
<!-- ci-dashboard-badge:end -->

## What does this PR do?

Encoder-decoder models build `decoder_input_ids` by right-shifting the target (via `shift_tokens_right`), so the logits are already aligned with `labels`. When such a model computes its training loss through `self.loss_function` (→ `ForCausalLMLoss`) **without** passing `shift_labels`, `ForCausalLMLoss` shifts the labels a second time (`labels[..., 1:]`), so the model trains against `labels[..., 1:]` instead of `labels` — an off-by-one in the training loss.

This PR fixes the affected models and adds a generic regression guard:

- **PPFormulaNet** and **CohereASR**: pass `shift_labels=labels` into the existing `self.loss_function` so the labels are not shifted again, preserving the loss path and `num_items_in_batch` handling. Edits are made in the `modular_*.py` files; the `modeling_*.py` files are regenerated. Only the training loss (when `labels` are passed) changes; logits and `generate()` are unchanged, and `-100` stays ignored.
- A static scan for the pattern (right-shift into `decoder_input_ids` + loss via `self.loss_function`) found only PPFormulaNet, CohereASR, and Florence2; Florence2 is handled separately.

Fixes #46901.

## Test

Adds a generic `test_encoder_decoder_loss_no_double_shift` to `tests/test_modeling_common.py`, gated on `config.is_encoder_decoder`. It feeds non-degenerate labels, lets the model build `decoder_input_ids` by right-shifting them, and asserts the loss is closer to a cross-entropy against `labels` than to one against `labels[..., 1:]`. Encoder-decoder models with no checkable supervised-loss path are skipped. This replaces the earlier PPFormulaNet-specific test, and is mutation-checked (removing `shift_labels=labels` makes it fail).

```
test_encoder_decoder_loss_no_double_shift: 33 passed, 60 skipped, 0 failed
PPFormulaNet: 112 passed, 134 skipped
CohereASR: 115 passed, 134 skipped
make style: passed
modular conversion check: passed
```

## Note

AI assistance was used while preparing this change; I have reviewed every line and run the tests.

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=46903)
**Latest run:** [28372907914:2](https://github.com/huggingface/transformers/actions/runs/28372907914)
**Result:** `success` | **Jobs:** 14 | **Tests:** 49,531 | **Failures:** 0 | **Duration:** 10h 38m

<!-- ci-dashboard-recap:end -->

Comments:
Updated the fix to use `self.loss_function(..., shift_labels=labels, **kwargs)` (per review) and re-ran locally on the new commit.

**Tests**
- `python -m pytest tests/models/pp_formulanet/test_modeling_pp_formulanet.py -q` → 112 passed, 134 skipped
- `ruff check src/transformers/models/pp_formulanet/ tests/models/pp_formulanet/test_modeling_pp_formulanet.py` → All checks passed
- `ruff format --check src/transformers/models/pp_formulanet/ tests/models/pp_formulanet/test_modeling_pp_formulanet.py` → 7 files already formatted
- `python utils/check_modular_conversion.py --files src/transformers/models/pp_formulanet/modular_pp_formulanet.py` → passed
- Mutation check: removing `shift_labels=labels` makes `test_training_loss_no_double_shift` fail; regenerating from the modular restores it.


Done — pushed the generic common test and the other affected model requested here.

**Common test.** Added `test_encoder_decoder_loss_no_double_shift` to `tests/test_modeling_common.py`, gated on `config.is_encoder_decoder`. It feeds non-degenerate labels, lets the model build `decoder_input_ids` by right-shifting them, and asserts the loss is closer to CE against `labels` than to CE against `labels[..., 1:]`. Encoder-decoder models with no checkable supervised-loss path are skipped. I moved the PPFormulaNet regression coverage into this common test and removed the per-model test.

**Other affected models.** A static scan for the pattern (right-shift into `decoder_input_ids` + loss via `self.loss_function`) found CohereASR only, besides PPFormulaNet and Florence2. Fixed CohereASR the same way: `self.loss_function(..., shift_labels=labels)` in `modular_cohere_asr.py`, then regenerated.

**Validation (local):**
- `test_encoder_decoder_loss_no_double_shift`: 33 passed, 60 skipped, 18866 deselected, 0 failed
- Full PPFormulaNet tests: 112 passed, 134 skipped
- Full CohereASR tests: 115 passed, 134 skipped
- `make style`: passed
- modular conversion check: passed


**[For maintainers]** Suggested jobs to run (before merge)

run-slow: cohere_asr, pp_formulanet