Skip to content

Commit a80169b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent eb55abe commit a80169b

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

monai/networks/blocks/crossattention.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import torch
1515
import torch.nn as nn
16-
from typing import Optional
1716

1817
from monai.networks.layers.utils import get_rel_pos_embedding_layer
1918
from monai.utils import optional_import
@@ -140,7 +139,7 @@ def __init__(
140139
)
141140
self.input_size = input_size
142141

143-
def forward(self, x: torch.Tensor, context: Optional[torch.Tensor] = None):
142+
def forward(self, x: torch.Tensor, context: torch.Tensor | None = None):
144143
"""
145144
Args:
146145
x (torch.Tensor): input tensor. B x (s_dim_1 * ... * s_dim_n) x C

monai/networks/blocks/selfattention.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import torch
1515
import torch.nn as nn
1616
import torch.nn.functional as F
17-
from typing import Optional
1817

1918
from monai.networks.layers.utils import get_rel_pos_embedding_layer
2019
from monai.utils import optional_import
@@ -159,7 +158,7 @@ def __init__(
159158
)
160159
self.input_size = input_size
161160

162-
def forward(self, x, attn_mask: Optional[torch.Tensor] = None):
161+
def forward(self, x, attn_mask: torch.Tensor | None = None):
163162
"""
164163
Args:
165164
x (torch.Tensor): input tensor. B x (s_dim_1 * ... * s_dim_n) x C

monai/networks/blocks/transformerblock.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import torch
1515
import torch.nn as nn
16-
from typing import Optional
1716

1817
from monai.networks.blocks import CrossAttentionBlock, MLPBlock, SABlock
1918

@@ -90,7 +89,7 @@ def __init__(
9089
)
9190

9291
def forward(
93-
self, x: torch.Tensor, context: Optional[torch.Tensor] = None, attn_mask: Optional[torch.Tensor] = None
92+
self, x: torch.Tensor, context: torch.Tensor | None = None, attn_mask: torch.Tensor | None = None
9493
) -> torch.Tensor:
9594
x = x + self.attn(self.norm1(x), attn_mask=attn_mask)
9695
if self.with_cross_attention:

0 commit comments

Comments
 (0)