[BE][Easy]: Simplify ModuleList reversed method (#151673)

Removes unnecessary list calls now that we are in Python 3.9 and KeyViews implement reversed directly.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151673
Approved by: https://github.com/albanD
This commit is contained in:
Aaron Gokaslan 2025-04-18 18:39:28 +00:00 committed by PyTorch MergeBot
parent b7807759de
commit cccfc146fe

View File

@ -809,7 +809,7 @@ class ParameterDict(Module):
return iter(self._keys) return iter(self._keys)
def __reversed__(self) -> Iterator[str]: def __reversed__(self) -> Iterator[str]:
return reversed(list(self._keys)) return reversed(self._keys)
def copy(self) -> ParameterDict: def copy(self) -> ParameterDict:
"""Return a copy of this :class:`~torch.nn.ParameterDict` instance.""" """Return a copy of this :class:`~torch.nn.ParameterDict` instance."""