diff --git a/torchvision/models/googlenet.py b/torchvision/models/googlenet.py index c973340e2ca..eb774d166ac 100644 --- a/torchvision/models/googlenet.py +++ b/torchvision/models/googlenet.py @@ -1,6 +1,5 @@ import warnings from collections import namedtuple -from typing import Union import torch import torch.nn as nn import torch.nn.functional as F @@ -194,11 +193,11 @@ def _forward(self, x): return x, aux2, aux1 @torch.jit.unused - def eager_outputs(self, x: Tensor, aux2: Tensor, aux1: Optional[Tensor]) -> Union[GoogLeNetOutputs, Tensor]: + def eager_outputs(self, x: Tensor, aux2: Tensor, aux1: Optional[Tensor]) -> GoogLeNetOutputs: if self.training and self.aux_logits: return _GoogLeNetOutputs(x, aux2, aux1) else: - return x + return x # type: ignore[return-value] def forward(self, x): # type: (Tensor) -> GoogLeNetOutputs diff --git a/torchvision/models/inception.py b/torchvision/models/inception.py index 6818dac874e..a131c8c754f 100644 --- a/torchvision/models/inception.py +++ b/torchvision/models/inception.py @@ -1,6 +1,5 @@ from collections import namedtuple import warnings -from typing import Union import torch import torch.nn as nn import torch.nn.functional as F @@ -189,11 +188,11 @@ def _forward(self, x): return x, aux @torch.jit.unused - def eager_outputs(self, x: torch.Tensor, aux: Optional[Tensor]) -> Union[InceptionOutputs, torch.Tensor]: + def eager_outputs(self, x: torch.Tensor, aux: Optional[Tensor]) -> InceptionOutputs: if self.training and self.aux_logits: return InceptionOutputs(x, aux) else: - return x + return x # type: ignore[return-value] def forward(self, x): x = self._transform_input(x)