Update deprecated type hinting in models (#18132)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-05-15 06:06:50 +01:00
committed by GitHub
parent 83f74c698f
commit 26d0419309
130 changed files with 971 additions and 901 deletions

View File

@@ -9,10 +9,9 @@ import copy
import math
import re
import unicodedata
from collections.abc import Collection, Mapping, Sequence
from collections.abc import Set as AbstractSet
from collections.abc import Collection, Mapping, Sequence, Set
from functools import lru_cache, partial
from typing import Callable, List, Literal, Optional, TypedDict, Union
from typing import Callable, Literal, Optional, TypedDict, Union
import torch
from torch import nn
@@ -395,7 +394,7 @@ def _get_tokenizer_without_image_pad(
def tokenize(
self,
text: str,
allowed_special: Union[AbstractSet[str], str] = "all",
allowed_special: Union[Set[str], str] = "all",
disallowed_special: Union[Collection[str], str] = (),
**kwargs,
) -> list[Union[bytes, str]]:
@@ -411,7 +410,7 @@ def _get_tokenizer_without_image_pad(
def _decode(
self,
token_ids: Union[int, List[int]],
token_ids: Union[int, list[int]],
skip_special_tokens: bool = False,
errors: Optional[str] = None,
**kwargs,