Split DequeReverseIteratorVariable off DequeIteratorVariable to match CPython (#194348)
Summary:
## Summary
In CPython, `_deque_reverse_iterator` is not a subclass of `_deque_iterator`:
```
>>> from collections import deque
>>> issubclass(type(reversed(deque())), type(iter(deque())))
False
```
`dir()` on both is the same (`__iter__`, `__next__`, `__length_hint__`). Dynamo still had `DequeReverseIteratorVariable(DequeIteratorVariable)`, so every `isinstance(x, DequeIteratorVariable)` check also matched reverse deque iterators.
This follows the same shape as #193261 (deque forward) and #193717 (tuple): reparent onto the existing `BaseListIteratorVariable` so the two deque iterator VTs are siblings. No new base class.
The deque mutation snapshot (`source_deque` / `saved_state`) cannot be inherited from `DequeIteratorVariable` after the split, or reverse iterators would still type-check as deque iterators. It is copied onto `DequeReverseIteratorVariable` so `reversed(d)` still raises `RuntimeError: deque mutated during iteration`.
### Files touched
| File | What changed |
| --- | --- |
| `torch/_dynamo/variables/lists.py` | `DequeReverseIteratorVariable` now subclasses `BaseListIteratorVariable`. Mutation snapshot copied so reverse iterators stay siblings. |
| `torch/_dynamo/symbolic_convert.py` | `GET_YIELD_FROM_ITER` lists `DequeReverseIteratorVariable` explicitly (same pattern as list/tuple/deque after #193717). |
| `torch/_dynamo/utils.py` | `_unpack_fast_types` adds `DequeReverseIteratorVariable` so reverse deque unpack keeps the fast path. |
| `torch/_dynamo/variables/__init__.py` | Import `DequeReverseIteratorVariable` (not exported in `__all__`, same as `DequeIteratorVariable`). |
| `test/dynamo/test_iterators.py` | Hierarchy, `yield from reversed(deque)`, and `type(reversed(deque))` regression tests. |
Not touched: `side_effects.py`. Deque iterators are built sourceless with `ValueMutationNew` and never hit the list/tuple iterator replay handler (#193261). Reverse is the same.
Part of #192874
## Test plan
```
python test/dynamo/test_iterators.py TestIterators.test_deque_reverse_iterator_not_a_deque_iterator
python test/dynamo/test_iterators.py TestIterators.test_yield_from_deque_reverse_iterator
python test/dynamo/test_iterators.py TestIterators.test_deque_reverse_iterator_python_type
python test/dynamo/test_iterators.py
python test/dynamo/test_sequence_ops.py -k deque_reverse
```
X-link: https://github.com/pytorch/pytorch/pull/194348
Approved by: https://github.com/guilhermeleobas, https://github.com/hameerabbasi
Reviewed By: huydhn
Differential Revision: D118488968
fbshipit-source-id: 9e6eaa7b62840a79cf2951c5b91d4cfc65007064
Author
generatedunixname499836121