diff --git a/examples/flax/image-captioning/run_image_captioning_flax.py b/examples/flax/image-captioning/run_image_captioning_flax.py index b16e68bbc6311f..f30274215ca8b1 100644 --- a/examples/flax/image-captioning/run_image_captioning_flax.py +++ b/examples/flax/image-captioning/run_image_captioning_flax.py @@ -22,7 +22,6 @@ import os import sys import time -import warnings from dataclasses import asdict, dataclass, field from enum import Enum from functools import partial @@ -192,12 +191,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -406,15 +399,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_image_captioning", model_args, data_args, framework="flax") diff --git a/examples/flax/language-modeling/run_bart_dlm_flax.py b/examples/flax/language-modeling/run_bart_dlm_flax.py index e5cbe5cd0fdba6..53a8da676e08a3 100644 --- a/examples/flax/language-modeling/run_bart_dlm_flax.py +++ b/examples/flax/language-modeling/run_bart_dlm_flax.py @@ -26,7 +26,6 @@ import os import sys import time -import warnings from dataclasses import asdict, dataclass, field from enum import Enum from itertools import chain @@ -178,12 +177,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) @dataclass @@ -470,15 +463,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_bart_dlm", model_args, data_args, framework="flax") diff --git a/examples/flax/language-modeling/run_clm_flax.py b/examples/flax/language-modeling/run_clm_flax.py index 48bad1a04c6d10..5f40b6254b1b7e 100755 --- a/examples/flax/language-modeling/run_clm_flax.py +++ b/examples/flax/language-modeling/run_clm_flax.py @@ -27,7 +27,6 @@ import os import sys import time -import warnings from dataclasses import asdict, dataclass, field from enum import Enum from itertools import chain @@ -179,12 +178,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -351,15 +344,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_clm", model_args, data_args, framework="flax") diff --git a/examples/flax/language-modeling/run_mlm_flax.py b/examples/flax/language-modeling/run_mlm_flax.py index ccd0f2bf20d976..d793cc3a37f7de 100755 --- a/examples/flax/language-modeling/run_mlm_flax.py +++ b/examples/flax/language-modeling/run_mlm_flax.py @@ -26,7 +26,6 @@ import os import sys import time -import warnings from dataclasses import asdict, dataclass, field from enum import Enum from itertools import chain @@ -184,12 +183,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -394,15 +387,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_mlm", model_args, data_args, framework="flax") diff --git a/examples/flax/language-modeling/run_t5_mlm_flax.py b/examples/flax/language-modeling/run_t5_mlm_flax.py index 06384deac457f0..caa70fe5149133 100755 --- a/examples/flax/language-modeling/run_t5_mlm_flax.py +++ b/examples/flax/language-modeling/run_t5_mlm_flax.py @@ -25,7 +25,6 @@ import os import sys import time -import warnings from dataclasses import asdict, dataclass, field # You can also adapt this script on your own masked language modeling task. Pointers for this are left as comments. @@ -178,12 +177,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) @dataclass @@ -511,15 +504,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_t5_mlm", model_args, data_args, framework="flax") diff --git a/examples/flax/question-answering/run_qa.py b/examples/flax/question-answering/run_qa.py index aa48bb4aea4bb8..0d889288fc30db 100644 --- a/examples/flax/question-answering/run_qa.py +++ b/examples/flax/question-answering/run_qa.py @@ -25,7 +25,6 @@ import random import sys import time -import warnings from dataclasses import asdict, dataclass, field from enum import Enum from pathlib import Path @@ -165,12 +164,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -455,15 +448,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_qa", model_args, data_args, framework="flax") diff --git a/examples/flax/summarization/run_summarization_flax.py b/examples/flax/summarization/run_summarization_flax.py index 391cd8cba77f67..bead750720e752 100644 --- a/examples/flax/summarization/run_summarization_flax.py +++ b/examples/flax/summarization/run_summarization_flax.py @@ -24,7 +24,6 @@ import os import sys import time -import warnings from dataclasses import asdict, dataclass, field from enum import Enum from functools import partial @@ -198,12 +197,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -434,15 +427,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_summarization", model_args, data_args, framework="flax") diff --git a/examples/flax/vision/run_image_classification.py b/examples/flax/vision/run_image_classification.py index d8011867957cd2..0228a8797b6edd 100644 --- a/examples/flax/vision/run_image_classification.py +++ b/examples/flax/vision/run_image_classification.py @@ -24,7 +24,6 @@ import os import sys import time -import warnings from dataclasses import asdict, dataclass, field from enum import Enum from pathlib import Path @@ -169,12 +168,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -274,15 +267,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_image_classification", model_args, data_args, framework="flax") diff --git a/examples/pytorch/audio-classification/run_audio_classification.py b/examples/pytorch/audio-classification/run_audio_classification.py index 8c1cb0afc67cdd..7da34ec1521b35 100644 --- a/examples/pytorch/audio-classification/run_audio_classification.py +++ b/examples/pytorch/audio-classification/run_audio_classification.py @@ -161,12 +161,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -214,15 +208,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_audio_classification", model_args, data_args) diff --git a/examples/pytorch/contrastive-image-text/run_clip.py b/examples/pytorch/contrastive-image-text/run_clip.py index bc319d8d550e15..e43094edcfa2c2 100644 --- a/examples/pytorch/contrastive-image-text/run_clip.py +++ b/examples/pytorch/contrastive-image-text/run_clip.py @@ -26,7 +26,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -96,12 +95,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -252,15 +245,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_clip", model_args, data_args) diff --git a/examples/pytorch/image-classification/run_image_classification.py b/examples/pytorch/image-classification/run_image_classification.py index a98ca3d235bd2c..04a8bbdf328cfa 100755 --- a/examples/pytorch/image-classification/run_image_classification.py +++ b/examples/pytorch/image-classification/run_image_classification.py @@ -16,7 +16,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -161,12 +160,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -196,15 +189,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_image_classification", model_args, data_args) diff --git a/examples/pytorch/image-pretraining/run_mae.py b/examples/pytorch/image-pretraining/run_mae.py index 0149504c924e37..0c1c59c467dbfd 100644 --- a/examples/pytorch/image-pretraining/run_mae.py +++ b/examples/pytorch/image-pretraining/run_mae.py @@ -16,7 +16,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -143,12 +142,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) mask_ratio: float = field( default=0.75, metadata={"help": "The ratio of the number of masked tokens in the input sequence."} ) @@ -182,15 +175,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_mae", model_args, data_args) diff --git a/examples/pytorch/image-pretraining/run_mim.py b/examples/pytorch/image-pretraining/run_mim.py index 7fd2ada795cdbc..8e51c79265068c 100644 --- a/examples/pytorch/image-pretraining/run_mim.py +++ b/examples/pytorch/image-pretraining/run_mim.py @@ -16,7 +16,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -163,12 +162,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -256,15 +249,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_mim", model_args, data_args) diff --git a/examples/pytorch/image-pretraining/run_mim_no_trainer.py b/examples/pytorch/image-pretraining/run_mim_no_trainer.py index 978e48d00022c8..bce8ce6bb69e31 100644 --- a/examples/pytorch/image-pretraining/run_mim_no_trainer.py +++ b/examples/pytorch/image-pretraining/run_mim_no_trainer.py @@ -17,7 +17,6 @@ import logging import math import os -import warnings from pathlib import Path import datasets @@ -196,12 +195,6 @@ def parse_args(): "generated when running `huggingface-cli login` (stored in `~/.huggingface`)." ), ) - parser.add_argument( - "--use_auth_token", - type=bool, - default=None, - help="The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - ) parser.add_argument( "--trust_remote_code", type=bool, @@ -384,15 +377,6 @@ def collate_fn(examples): def main(): args = parse_args() - if args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - args.token = args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_mim_no_trainer", args) diff --git a/examples/pytorch/language-modeling/run_clm.py b/examples/pytorch/language-modeling/run_clm.py index de0c51190c9b86..9b089d6d2fb283 100755 --- a/examples/pytorch/language-modeling/run_clm.py +++ b/examples/pytorch/language-modeling/run_clm.py @@ -25,7 +25,6 @@ import math import os import sys -import warnings from dataclasses import dataclass, field from itertools import chain from typing import Optional @@ -121,12 +120,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -255,15 +248,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_clm", model_args, data_args) diff --git a/examples/pytorch/language-modeling/run_mlm.py b/examples/pytorch/language-modeling/run_mlm.py index fd271d68476d11..ca0034fb759402 100755 --- a/examples/pytorch/language-modeling/run_mlm.py +++ b/examples/pytorch/language-modeling/run_mlm.py @@ -25,7 +25,6 @@ import math import os import sys -import warnings from dataclasses import dataclass, field from itertools import chain from typing import Optional @@ -118,12 +117,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -266,15 +259,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_mlm", model_args, data_args) diff --git a/examples/pytorch/language-modeling/run_plm.py b/examples/pytorch/language-modeling/run_plm.py index ee1aaa599d96f7..c151ac167ac61e 100755 --- a/examples/pytorch/language-modeling/run_plm.py +++ b/examples/pytorch/language-modeling/run_plm.py @@ -22,7 +22,6 @@ import math import os import sys -import warnings from dataclasses import dataclass, field from itertools import chain from typing import Optional @@ -105,12 +104,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) low_cpu_mem_usage: bool = field( default=False, metadata={ @@ -236,15 +229,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_plm", model_args, data_args) diff --git a/examples/pytorch/multiple-choice/run_swag.py b/examples/pytorch/multiple-choice/run_swag.py index 2a6c701d6d3cd2..32407d4a2d74e2 100755 --- a/examples/pytorch/multiple-choice/run_swag.py +++ b/examples/pytorch/multiple-choice/run_swag.py @@ -21,7 +21,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union @@ -89,12 +88,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -242,15 +235,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_swag", model_args, data_args) diff --git a/examples/pytorch/question-answering/run_qa.py b/examples/pytorch/question-answering/run_qa.py index ba8e955336ef5b..6c9071322c81ec 100755 --- a/examples/pytorch/question-answering/run_qa.py +++ b/examples/pytorch/question-answering/run_qa.py @@ -89,12 +89,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -244,15 +238,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_qa", model_args, data_args) diff --git a/examples/pytorch/question-answering/run_qa_beam_search.py b/examples/pytorch/question-answering/run_qa_beam_search.py index f5003acd96cce1..15492ace6f75c4 100755 --- a/examples/pytorch/question-answering/run_qa_beam_search.py +++ b/examples/pytorch/question-answering/run_qa_beam_search.py @@ -21,7 +21,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -88,12 +87,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) @dataclass @@ -233,15 +226,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_qa_beam_search", model_args, data_args) diff --git a/examples/pytorch/question-answering/run_seq2seq_qa.py b/examples/pytorch/question-answering/run_seq2seq_qa.py index 3e5e5f4f53b353..0f30a4d0552021 100644 --- a/examples/pytorch/question-answering/run_seq2seq_qa.py +++ b/examples/pytorch/question-answering/run_seq2seq_qa.py @@ -21,7 +21,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import List, Optional, Tuple @@ -90,12 +89,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -290,15 +283,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_seq2seq_qa", model_args, data_args) diff --git a/examples/pytorch/semantic-segmentation/run_semantic_segmentation.py b/examples/pytorch/semantic-segmentation/run_semantic_segmentation.py index 5e3c8b6eeb24c3..c5cc5d7207b129 100644 --- a/examples/pytorch/semantic-segmentation/run_semantic_segmentation.py +++ b/examples/pytorch/semantic-segmentation/run_semantic_segmentation.py @@ -17,7 +17,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from functools import partial from typing import Optional @@ -151,12 +150,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -182,15 +175,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_semantic_segmentation", model_args, data_args) diff --git a/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py b/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py index d80d470b4308b2..1fba871f29311e 100755 --- a/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py +++ b/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py @@ -251,12 +251,6 @@ class DataTrainingArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -411,15 +405,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if data_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if data_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - data_args.token = data_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_speech_recognition_ctc", model_args, data_args) diff --git a/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py b/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py index 3715ae7b029c49..78b48f50f1244b 100755 --- a/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py +++ b/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py @@ -241,12 +241,6 @@ class DataTrainingArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -391,15 +385,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if data_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if data_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - data_args.token = data_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_speech_recognition_ctc_adapter", model_args, data_args) diff --git a/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py b/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py index 943dff1894ed0e..59d097fc72426e 100755 --- a/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py +++ b/examples/pytorch/speech-recognition/run_speech_recognition_seq2seq.py @@ -22,7 +22,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union @@ -95,12 +94,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -295,15 +288,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_speech_recognition_seq2seq", model_args, data_args) diff --git a/examples/pytorch/summarization/run_summarization.py b/examples/pytorch/summarization/run_summarization.py index 261ea8a909c804..3ca6ec7e918fa4 100755 --- a/examples/pytorch/summarization/run_summarization.py +++ b/examples/pytorch/summarization/run_summarization.py @@ -21,7 +21,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -109,12 +108,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -329,15 +322,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_summarization", model_args, data_args) diff --git a/examples/pytorch/text-classification/run_classification.py b/examples/pytorch/text-classification/run_classification.py index 40456b5e9397de..b5f796e1588384 100755 --- a/examples/pytorch/text-classification/run_classification.py +++ b/examples/pytorch/text-classification/run_classification.py @@ -20,7 +20,6 @@ import os import random import sys -import warnings from dataclasses import dataclass, field from typing import List, Optional @@ -237,12 +236,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -285,15 +278,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_classification", model_args, data_args) diff --git a/examples/pytorch/text-classification/run_glue.py b/examples/pytorch/text-classification/run_glue.py index 197e9cbe41426d..18bd5cbc689b2f 100755 --- a/examples/pytorch/text-classification/run_glue.py +++ b/examples/pytorch/text-classification/run_glue.py @@ -20,7 +20,6 @@ import os import random import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -198,12 +197,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -233,15 +226,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_glue", model_args, data_args) diff --git a/examples/pytorch/text-classification/run_xnli.py b/examples/pytorch/text-classification/run_xnli.py index 4882f2e8c4c428..479fc162120fbb 100755 --- a/examples/pytorch/text-classification/run_xnli.py +++ b/examples/pytorch/text-classification/run_xnli.py @@ -21,7 +21,6 @@ import os import random import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -162,12 +161,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -192,15 +185,6 @@ def main(): parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments)) model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_xnli", model_args) diff --git a/examples/pytorch/token-classification/run_ner.py b/examples/pytorch/token-classification/run_ner.py index b6dbc9807da5e9..90c616b3cb3083 100755 --- a/examples/pytorch/token-classification/run_ner.py +++ b/examples/pytorch/token-classification/run_ner.py @@ -22,7 +22,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -89,12 +88,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -234,15 +227,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_ner", model_args, data_args) diff --git a/examples/pytorch/translation/run_translation.py b/examples/pytorch/translation/run_translation.py index f155141426140e..4954f3b996582f 100755 --- a/examples/pytorch/translation/run_translation.py +++ b/examples/pytorch/translation/run_translation.py @@ -21,7 +21,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -99,12 +98,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -278,15 +271,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_translation", model_args, data_args) diff --git a/examples/tensorflow/contrastive-image-text/run_clip.py b/examples/tensorflow/contrastive-image-text/run_clip.py index e26e2dd9c00e6f..24873df6664eca 100644 --- a/examples/tensorflow/contrastive-image-text/run_clip.py +++ b/examples/tensorflow/contrastive-image-text/run_clip.py @@ -26,7 +26,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -102,12 +101,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -262,15 +255,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - if model_args.model_name_or_path is not None: if model_args.vision_model_name_or_path is not None or model_args.text_model_name_or_path is not None: raise ValueError( diff --git a/examples/tensorflow/image-classification/run_image_classification.py b/examples/tensorflow/image-classification/run_image_classification.py index f303fe11f0216e..29174b068727a2 100644 --- a/examples/tensorflow/image-classification/run_image_classification.py +++ b/examples/tensorflow/image-classification/run_image_classification.py @@ -23,7 +23,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -168,12 +167,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -244,18 +237,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - - if not (training_args.do_train or training_args.do_eval or training_args.do_predict): - exit("Must specify at least one of --do_train, --do_eval or --do_predict!") - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/TensorFlow versions. send_example_telemetry("run_image_classification", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/language-modeling/run_clm.py b/examples/tensorflow/language-modeling/run_clm.py index 5c941016d57d75..a75cf9bf1d3ce2 100755 --- a/examples/tensorflow/language-modeling/run_clm.py +++ b/examples/tensorflow/language-modeling/run_clm.py @@ -30,7 +30,6 @@ import os import random import sys -import warnings from dataclasses import dataclass, field from itertools import chain from pathlib import Path @@ -122,12 +121,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -237,15 +230,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_clm", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/language-modeling/run_mlm.py b/examples/tensorflow/language-modeling/run_mlm.py index b14648b2c9cc73..43b991e7fe2887 100755 --- a/examples/tensorflow/language-modeling/run_mlm.py +++ b/examples/tensorflow/language-modeling/run_mlm.py @@ -28,7 +28,6 @@ import os import random import sys -import warnings from dataclasses import dataclass, field from itertools import chain from pathlib import Path @@ -120,12 +119,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -243,15 +236,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_mlm", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/multiple-choice/run_swag.py b/examples/tensorflow/multiple-choice/run_swag.py index 63d02839ffa0bf..ccc733892ae6c4 100644 --- a/examples/tensorflow/multiple-choice/run_swag.py +++ b/examples/tensorflow/multiple-choice/run_swag.py @@ -22,7 +22,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from itertools import chain from pathlib import Path @@ -156,12 +155,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -256,15 +249,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_swag", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/question-answering/run_qa.py b/examples/tensorflow/question-answering/run_qa.py index 7cd9dab07d1d82..96d260bd3e6b48 100755 --- a/examples/tensorflow/question-answering/run_qa.py +++ b/examples/tensorflow/question-answering/run_qa.py @@ -22,7 +22,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from pathlib import Path from typing import Optional @@ -101,12 +100,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -276,15 +269,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_qa", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/summarization/run_summarization.py b/examples/tensorflow/summarization/run_summarization.py index 88fc675da3d0b5..29a88731aed93b 100644 --- a/examples/tensorflow/summarization/run_summarization.py +++ b/examples/tensorflow/summarization/run_summarization.py @@ -22,7 +22,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -109,12 +108,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -304,15 +297,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_summarization", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/text-classification/run_glue.py b/examples/tensorflow/text-classification/run_glue.py index 11dfbfaafad45b..48c9d3cbedbb26 100644 --- a/examples/tensorflow/text-classification/run_glue.py +++ b/examples/tensorflow/text-classification/run_glue.py @@ -20,7 +20,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -174,12 +173,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -209,15 +202,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_glue", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/text-classification/run_text_classification.py b/examples/tensorflow/text-classification/run_text_classification.py index 47b8b768503b8b..e4f0644d1229fc 100644 --- a/examples/tensorflow/text-classification/run_text_classification.py +++ b/examples/tensorflow/text-classification/run_text_classification.py @@ -20,7 +20,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from pathlib import Path from typing import Optional @@ -194,12 +193,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -229,15 +222,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_text_classification", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/token-classification/run_ner.py b/examples/tensorflow/token-classification/run_ner.py index db8aa7af42ed8a..54a6e7b8855c44 100644 --- a/examples/tensorflow/token-classification/run_ner.py +++ b/examples/tensorflow/token-classification/run_ner.py @@ -21,7 +21,6 @@ import logging import os import random -import warnings from dataclasses import dataclass, field from typing import Optional @@ -85,12 +84,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -213,15 +206,6 @@ def main(): parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TFTrainingArguments)) model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_ner", model_args, data_args, framework="tensorflow") diff --git a/examples/tensorflow/translation/run_translation.py b/examples/tensorflow/translation/run_translation.py index 9e31268cb30153..24d7d6adb8f55f 100644 --- a/examples/tensorflow/translation/run_translation.py +++ b/examples/tensorflow/translation/run_translation.py @@ -22,7 +22,6 @@ import logging import os import sys -import warnings from dataclasses import dataclass, field from typing import Optional @@ -103,12 +102,6 @@ class ModelArguments: ) }, ) - use_auth_token: bool = field( - default=None, - metadata={ - "help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead." - }, - ) trust_remote_code: bool = field( default=False, metadata={ @@ -285,15 +278,6 @@ def main(): else: model_args, data_args, training_args = parser.parse_args_into_dataclasses() - if model_args.use_auth_token is not None: - warnings.warn( - "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token` instead.", - FutureWarning, - ) - if model_args.token is not None: - raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.") - model_args.token = model_args.use_auth_token - # Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The # information sent is the one passed as arguments along with your Python/PyTorch versions. send_example_telemetry("run_translation", model_args, data_args, framework="tensorflow") diff --git a/src/transformers/image_utils.py b/src/transformers/image_utils.py index 0db83f1bbb77ef..aaa9e4eadc6a2a 100644 --- a/src/transformers/image_utils.py +++ b/src/transformers/image_utils.py @@ -727,23 +727,11 @@ def rotate(self, image, angle, resample=None, expand=0, center=None, translate=N ) -def promote_annotation_format(annotation_format: Union[AnnotionFormat, AnnotationFormat]) -> AnnotationFormat: - # can be removed when `AnnotionFormat` is fully deprecated - return AnnotationFormat(annotation_format.value) - - def validate_annotations( annotation_format: AnnotationFormat, supported_annotation_formats: Tuple[AnnotationFormat, ...], annotations: List[Dict], ) -> None: - if isinstance(annotation_format, AnnotionFormat): - logger.warning_once( - f"`{annotation_format.__class__.__name__}` is deprecated and will be removed in v4.38. " - f"Please use `{AnnotationFormat.__name__}` instead." - ) - annotation_format = promote_annotation_format(annotation_format) - if annotation_format not in supported_annotation_formats: raise ValueError(f"Unsupported annotation format: {format} must be one of {supported_annotation_formats}") diff --git a/src/transformers/models/auto/image_processing_auto.py b/src/transformers/models/auto/image_processing_auto.py index a077a02e75a000..41a1fcf960ede1 100644 --- a/src/transformers/models/auto/image_processing_auto.py +++ b/src/transformers/models/auto/image_processing_auto.py @@ -371,22 +371,10 @@ def from_pretrained(cls, pretrained_model_name_or_path, **kwargs): if image_processor_class is None and image_processor_auto_map is None: feature_extractor_class = config_dict.pop("feature_extractor_type", None) if feature_extractor_class is not None: - logger.warning( - "Could not find image processor class in the image processor config or the model config. Loading " - "based on pattern matching with the model's feature extractor configuration. Please open a " - "PR/issue to update `preprocessor_config.json` to use `image_processor_type` instead of " - "`feature_extractor_type`. This warning will be removed in v4.40." - ) image_processor_class = feature_extractor_class.replace("FeatureExtractor", "ImageProcessor") if "AutoFeatureExtractor" in config_dict.get("auto_map", {}): feature_extractor_auto_map = config_dict["auto_map"]["AutoFeatureExtractor"] image_processor_auto_map = feature_extractor_auto_map.replace("FeatureExtractor", "ImageProcessor") - logger.warning( - "Could not find image processor auto map in the image processor config or the model config. " - "Loading based on pattern matching with the model's feature extractor configuration. Please open a " - "PR/issue to update `preprocessor_config.json` to use `AutoImageProcessor` instead of " - "`AutoFeatureExtractor`. This warning will be removed in v4.40." - ) # If we don't find the image processor class in the image processor config, let's try the model config. if image_processor_class is None and image_processor_auto_map is None: diff --git a/src/transformers/models/cohere/modeling_cohere.py b/src/transformers/models/cohere/modeling_cohere.py index eb6be4911b87cb..d6f37af8dabae5 100644 --- a/src/transformers/models/cohere/modeling_cohere.py +++ b/src/transformers/models/cohere/modeling_cohere.py @@ -23,7 +23,6 @@ """PyTorch Cohere model.""" import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -635,7 +634,6 @@ def forward( output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, cache_position: Optional[torch.LongTensor] = None, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: """ Args: @@ -651,11 +649,6 @@ def forward( (see `past_key_values`). past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states """ - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - residual = hidden_states hidden_states = self.input_layernorm(hidden_states) @@ -669,7 +662,6 @@ def forward( output_attentions=output_attentions, use_cache=use_cache, cache_position=cache_position, - **kwargs, ) # Fully Connected diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index e88bfc8fe230df..9aab526c09a40d 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -915,31 +915,6 @@ def prepare_annotation( raise ValueError(f"Format {format} is not supported.") return target - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare - def prepare(self, image, target, return_segmentation_masks=None, masks_path=None): - logger.warning_once( - "The `prepare` method is deprecated and will be removed in a v4.33. " - "Please use `prepare_annotation` instead. Note: the `prepare_annotation` method " - "does not return the image anymore.", - ) - target = self.prepare_annotation(image, target, return_segmentation_masks, masks_path, self.format) - return image, target - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.convert_coco_poly_to_mask - def convert_coco_poly_to_mask(self, *args, **kwargs): - logger.warning_once("The `convert_coco_poly_to_mask` method is deprecated and will be removed in v4.33. ") - return convert_coco_poly_to_mask(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_detection with DETR->ConditionalDetr - def prepare_coco_detection(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_detection` method is deprecated and will be removed in v4.33. ") - return prepare_coco_detection_annotation(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_panoptic - def prepare_coco_panoptic(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_panoptic` method is deprecated and will be removed in v4.33. ") - return prepare_coco_panoptic_annotation(*args, **kwargs) - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.resize def resize( self, diff --git a/src/transformers/models/conditional_detr/modeling_conditional_detr.py b/src/transformers/models/conditional_detr/modeling_conditional_detr.py index eec95205244f1a..7fd04b8b43b728 100644 --- a/src/transformers/models/conditional_detr/modeling_conditional_detr.py +++ b/src/transformers/models/conditional_detr/modeling_conditional_detr.py @@ -556,23 +556,7 @@ def __init__( def _shape(self, tensor: torch.Tensor, seq_len: int, batch_size: int): return tensor.view(batch_size, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous() - def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor], **kwargs): - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - + def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor]): return tensor if object_queries is None else tensor + object_queries def forward( @@ -583,38 +567,8 @@ def forward( key_value_states: Optional[torch.Tensor] = None, spatial_position_embeddings: Optional[torch.Tensor] = None, output_attentions: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: """Input shape: Batch x Time x Channel""" - - position_embeddings = kwargs.pop("position_ebmeddings", None) - key_value_position_embeddings = kwargs.pop("key_value_position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if key_value_position_embeddings is not None and spatial_position_embeddings is not None: - raise ValueError( - "Cannot specify both key_value_position_embeddings and spatial_position_embeddings. Please use just spatial_position_embeddings" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - - if key_value_position_embeddings is not None: - logger.warning_once( - "key_value_position_embeddings has been deprecated and will be removed in v4.34. Please use spatial_position_embeddings instead" - ) - spatial_position_embeddings = key_value_position_embeddings - # if key_value_states are provided this layer is used as a cross-attention layer # for the decoder is_cross_attention = key_value_states is not None @@ -838,7 +792,6 @@ def forward( attention_mask: torch.Tensor, object_queries: torch.Tensor = None, output_attentions: bool = False, - **kwargs, ): """ Args: @@ -852,22 +805,6 @@ def forward( Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned tensors for more detail. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - residual = hidden_states hidden_states, attn_weights = self.self_attn( hidden_states=hidden_states, @@ -956,7 +893,6 @@ def forward( encoder_attention_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = False, is_first: Optional[bool] = False, - **kwargs, ): """ Args: @@ -979,22 +915,6 @@ def forward( Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned tensors for more detail. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - residual = hidden_states # ========== Begin of Self-Attention ============= @@ -1236,7 +1156,6 @@ def forward( output_attentions=None, output_hidden_states=None, return_dict=None, - **kwargs, ): r""" Args: @@ -1263,22 +1182,6 @@ def forward( return_dict (`bool`, *optional*): Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions output_hidden_states = ( output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states @@ -1377,7 +1280,6 @@ def forward( output_attentions=None, output_hidden_states=None, return_dict=None, - **kwargs, ): r""" Args: @@ -1414,22 +1316,6 @@ def forward( return_dict (`bool`, *optional*): Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions output_hidden_states = ( output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index 5525eeeb8c58d5..e6587b7fb59a71 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -913,31 +913,6 @@ def prepare_annotation( raise ValueError(f"Format {format} is not supported.") return target - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare - def prepare(self, image, target, return_segmentation_masks=None, masks_path=None): - logger.warning_once( - "The `prepare` method is deprecated and will be removed in a v4.33. " - "Please use `prepare_annotation` instead. Note: the `prepare_annotation` method " - "does not return the image anymore.", - ) - target = self.prepare_annotation(image, target, return_segmentation_masks, masks_path, self.format) - return image, target - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.convert_coco_poly_to_mask - def convert_coco_poly_to_mask(self, *args, **kwargs): - logger.warning_once("The `convert_coco_poly_to_mask` method is deprecated and will be removed in v4.33. ") - return convert_coco_poly_to_mask(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_detection - def prepare_coco_detection(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_detection` method is deprecated and will be removed in v4.33. ") - return prepare_coco_detection_annotation(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_panoptic - def prepare_coco_panoptic(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_panoptic` method is deprecated and will be removed in v4.33. ") - return prepare_coco_panoptic_annotation(*args, **kwargs) - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.resize def resize( self, diff --git a/src/transformers/models/deta/image_processing_deta.py b/src/transformers/models/deta/image_processing_deta.py index 45c5c6cb285a8f..fd563d3009c883 100644 --- a/src/transformers/models/deta/image_processing_deta.py +++ b/src/transformers/models/deta/image_processing_deta.py @@ -576,31 +576,6 @@ def prepare_annotation( raise ValueError(f"Format {format} is not supported.") return target - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare - def prepare(self, image, target, return_segmentation_masks=None, masks_path=None): - logger.warning_once( - "The `prepare` method is deprecated and will be removed in a v4.33. " - "Please use `prepare_annotation` instead. Note: the `prepare_annotation` method " - "does not return the image anymore.", - ) - target = self.prepare_annotation(image, target, return_segmentation_masks, masks_path, self.format) - return image, target - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.convert_coco_poly_to_mask - def convert_coco_poly_to_mask(self, *args, **kwargs): - logger.warning_once("The `convert_coco_poly_to_mask` method is deprecated and will be removed in v4.33. ") - return convert_coco_poly_to_mask(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_detection - def prepare_coco_detection(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_detection` method is deprecated and will be removed in v4.33. ") - return prepare_coco_detection_annotation(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_panoptic - def prepare_coco_panoptic(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_panoptic` method is deprecated and will be removed in v4.33. ") - return prepare_coco_panoptic_annotation(*args, **kwargs) - def resize( self, image: np.ndarray, diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index e0e59cbc7c40c6..be4b0dec9f0a5f 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -896,27 +896,6 @@ def prepare_annotation( raise ValueError(f"Format {format} is not supported.") return target - def prepare(self, image, target, return_segmentation_masks=None, masks_path=None): - logger.warning_once( - "The `prepare` method is deprecated and will be removed in a v4.33. " - "Please use `prepare_annotation` instead. Note: the `prepare_annotation` method " - "does not return the image anymore.", - ) - target = self.prepare_annotation(image, target, return_segmentation_masks, masks_path, self.format) - return image, target - - def convert_coco_poly_to_mask(self, *args, **kwargs): - logger.warning_once("The `convert_coco_poly_to_mask` method is deprecated and will be removed in v4.33. ") - return convert_coco_poly_to_mask(*args, **kwargs) - - def prepare_coco_detection(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_detection` method is deprecated and will be removed in v4.33. ") - return prepare_coco_detection_annotation(*args, **kwargs) - - def prepare_coco_panoptic(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_panoptic` method is deprecated and will be removed in v4.33. ") - return prepare_coco_panoptic_annotation(*args, **kwargs) - def resize( self, image: np.ndarray, diff --git a/src/transformers/models/detr/modeling_detr.py b/src/transformers/models/detr/modeling_detr.py index 3ac3c13550af32..37da6b6ee59182 100644 --- a/src/transformers/models/detr/modeling_detr.py +++ b/src/transformers/models/detr/modeling_detr.py @@ -524,23 +524,7 @@ def __init__( def _shape(self, tensor: torch.Tensor, seq_len: int, batch_size: int): return tensor.view(batch_size, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous() - def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor], **kwargs): - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - + def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor]): return tensor if object_queries is None else tensor + object_queries def forward( @@ -551,38 +535,8 @@ def forward( key_value_states: Optional[torch.Tensor] = None, spatial_position_embeddings: Optional[torch.Tensor] = None, output_attentions: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: """Input shape: Batch x Time x Channel""" - - position_embeddings = kwargs.pop("position_ebmeddings", None) - key_value_position_embeddings = kwargs.pop("key_value_position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if key_value_position_embeddings is not None and spatial_position_embeddings is not None: - raise ValueError( - "Cannot specify both key_value_position_embeddings and spatial_position_embeddings. Please use just spatial_position_embeddings" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - - if key_value_position_embeddings is not None: - logger.warning_once( - "key_value_position_embeddings has been deprecated and will be removed in v4.34. Please use spatial_position_embeddings instead" - ) - spatial_position_embeddings = key_value_position_embeddings - # if key_value_states are provided this layer is used as a cross-attention layer # for the decoder is_cross_attention = key_value_states is not None @@ -688,7 +642,6 @@ def forward( attention_mask: torch.Tensor, object_queries: torch.Tensor = None, output_attentions: bool = False, - **kwargs, ): """ Args: @@ -702,22 +655,6 @@ def forward( Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned tensors for more detail. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - residual = hidden_states hidden_states, attn_weights = self.self_attn( hidden_states=hidden_states, @@ -787,7 +724,6 @@ def forward( encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = False, - **kwargs, ): """ Args: @@ -810,22 +746,6 @@ def forward( Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned tensors for more detail. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - residual = hidden_states # Self Attention @@ -995,7 +915,6 @@ def forward( output_attentions=None, output_hidden_states=None, return_dict=None, - **kwargs, ): r""" Args: @@ -1022,22 +941,6 @@ def forward( return_dict (`bool`, *optional*): Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions output_hidden_states = ( output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states @@ -1129,7 +1032,6 @@ def forward( output_attentions=None, output_hidden_states=None, return_dict=None, - **kwargs, ): r""" Args: @@ -1167,22 +1069,6 @@ def forward( return_dict (`bool`, *optional*): Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions output_hidden_states = ( output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states diff --git a/src/transformers/models/falcon/modeling_falcon.py b/src/transformers/models/falcon/modeling_falcon.py index a171c875dbdc0a..0a14fcb37b72cd 100644 --- a/src/transformers/models/falcon/modeling_falcon.py +++ b/src/transformers/models/falcon/modeling_falcon.py @@ -15,7 +15,6 @@ """PyTorch Falcon model.""" import math -import warnings from typing import TYPE_CHECKING, Optional, Tuple, Union import torch @@ -393,13 +392,7 @@ def forward( head_mask: Optional[torch.Tensor] = None, use_cache: bool = False, output_attentions: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - fused_qkv = self.query_key_value(hidden_states) # [batch_size, seq_length, 3 x hidden_size] num_kv_heads = self.num_heads if self.new_decoder_architecture else self.num_kv_heads # 3 x [batch_size, seq_length, num_heads, head_dim] @@ -549,16 +542,7 @@ def forward( head_mask: Optional[torch.Tensor] = None, use_cache: bool = False, output_attentions: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - - # overwrite attention_mask with padding_mask - attention_mask = kwargs.pop("padding_mask") - fused_qkv = self.query_key_value(hidden_states) # [batch_size, seq_length, 3 x hidden_size] num_kv_heads = self.num_heads if self.new_decoder_architecture else self.num_kv_heads # 3 x [batch_size, seq_length, num_heads, head_dim] @@ -792,13 +776,7 @@ def forward( head_mask: Optional[torch.Tensor] = None, use_cache: bool = False, output_attentions: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - residual = hidden_states if self.config.new_decoder_architecture and self.config.num_ln_in_parallel_attn == 2: @@ -817,7 +795,6 @@ def forward( head_mask=head_mask, use_cache=use_cache, output_attentions=output_attentions, - **kwargs, ) attention_output = attn_outputs[0] diff --git a/src/transformers/models/gemma/modeling_gemma.py b/src/transformers/models/gemma/modeling_gemma.py index d511e50dd9f22d..a3fc4b171de349 100644 --- a/src/transformers/models/gemma/modeling_gemma.py +++ b/src/transformers/models/gemma/modeling_gemma.py @@ -16,7 +16,6 @@ """ PyTorch Gemma model.""" import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -616,7 +615,6 @@ def forward( output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, cache_position: Optional[torch.LongTensor] = None, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: """ Args: @@ -632,11 +630,6 @@ def forward( (see `past_key_values`). past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states """ - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - residual = hidden_states hidden_states = self.input_layernorm(hidden_states) @@ -650,7 +643,6 @@ def forward( output_attentions=output_attentions, use_cache=use_cache, cache_position=cache_position, - **kwargs, ) hidden_states = residual + hidden_states diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index 8b39d6801ca000..0d7eebb7b3ea12 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -920,31 +920,6 @@ def prepare_annotation( raise ValueError(f"Format {format} is not supported.") return target - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare - def prepare(self, image, target, return_segmentation_masks=None, masks_path=None): - logger.warning_once( - "The `prepare` method is deprecated and will be removed in a v4.33. " - "Please use `prepare_annotation` instead. Note: the `prepare_annotation` method " - "does not return the image anymore.", - ) - target = self.prepare_annotation(image, target, return_segmentation_masks, masks_path, self.format) - return image, target - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.convert_coco_poly_to_mask - def convert_coco_poly_to_mask(self, *args, **kwargs): - logger.warning_once("The `convert_coco_poly_to_mask` method is deprecated and will be removed in v4.33. ") - return convert_coco_poly_to_mask(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_detection - def prepare_coco_detection(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_detection` method is deprecated and will be removed in v4.33. ") - return prepare_coco_detection_annotation(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_panoptic - def prepare_coco_panoptic(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_panoptic` method is deprecated and will be removed in v4.33. ") - return prepare_coco_panoptic_annotation(*args, **kwargs) - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.resize def resize( self, diff --git a/src/transformers/models/llama/modeling_llama.py b/src/transformers/models/llama/modeling_llama.py index e639eac3f5b8f6..ba02a7fc776afe 100644 --- a/src/transformers/models/llama/modeling_llama.py +++ b/src/transformers/models/llama/modeling_llama.py @@ -20,7 +20,6 @@ """PyTorch LLaMA model.""" import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -104,29 +103,6 @@ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, s self.register_buffer("inv_freq", inv_freq, persistent=False) # For BC we register cos and sin cached self.max_seq_len_cached = max_position_embeddings - t = torch.arange(self.max_seq_len_cached, device=device, dtype=torch.int64).type_as(self.inv_freq) - t = t / self.scaling_factor - freqs = torch.outer(t, self.inv_freq) - # Different from paper, but it uses a different permutation in order to obtain the same calculation - emb = torch.cat((freqs, freqs), dim=-1) - self.register_buffer("_cos_cached", emb.cos().to(torch.get_default_dtype()), persistent=False) - self.register_buffer("_sin_cached", emb.sin().to(torch.get_default_dtype()), persistent=False) - - @property - def sin_cached(self): - logger.warning_once( - "The sin_cached attribute will be removed in 4.39. Bear in mind that its contents changed in v4.38. Use " - "the forward method of RoPE from now on instead. It is not used in the `LlamaAttention` class" - ) - return self._sin_cached - - @property - def cos_cached(self): - logger.warning_once( - "The cos_cached attribute will be removed in 4.39. Bear in mind that its contents changed in v4.38. Use " - "the forward method of RoPE from now on instead. It is not used in the `LlamaAttention` class" - ) - return self._cos_cached @torch.no_grad() def forward(self, x, position_ids): @@ -714,7 +690,6 @@ def forward( output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, cache_position: Optional[torch.LongTensor] = None, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: """ Args: @@ -730,11 +705,6 @@ def forward( (see `past_key_values`). past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states """ - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - residual = hidden_states hidden_states = self.input_layernorm(hidden_states) @@ -748,7 +718,6 @@ def forward( output_attentions=output_attentions, use_cache=use_cache, cache_position=cache_position, - **kwargs, ) hidden_states = residual + hidden_states diff --git a/src/transformers/models/maskformer/modeling_maskformer.py b/src/transformers/models/maskformer/modeling_maskformer.py index 74cc6cc4c9e9e3..2c2746603ac633 100644 --- a/src/transformers/models/maskformer/modeling_maskformer.py +++ b/src/transformers/models/maskformer/modeling_maskformer.py @@ -440,23 +440,7 @@ def __init__( def _shape(self, tensor: torch.Tensor, seq_len: int, batch_size: int): return tensor.view(batch_size, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous() - def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor], **kwargs): - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - + def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor]): return tensor if object_queries is None else tensor + object_queries def forward( @@ -467,38 +451,8 @@ def forward( key_value_states: Optional[torch.Tensor] = None, spatial_position_embeddings: Optional[torch.Tensor] = None, output_attentions: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: """Input shape: Batch x Time x Channel""" - - position_embeddings = kwargs.pop("position_ebmeddings", None) - key_value_position_embeddings = kwargs.pop("key_value_position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if key_value_position_embeddings is not None and spatial_position_embeddings is not None: - raise ValueError( - "Cannot specify both key_value_position_embeddings and spatial_position_embeddings. Please use just spatial_position_embeddings" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - - if key_value_position_embeddings is not None: - logger.warning_once( - "key_value_position_embeddings has been deprecated and will be removed in v4.34. Please use spatial_position_embeddings instead" - ) - spatial_position_embeddings = key_value_position_embeddings - # if key_value_states are provided this layer is used as a cross-attention layer # for the decoder is_cross_attention = key_value_states is not None @@ -616,7 +570,6 @@ def forward( encoder_hidden_states: Optional[torch.Tensor] = None, encoder_attention_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = False, - **kwargs, ): """ Args: @@ -639,22 +592,6 @@ def forward( Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned tensors for more detail. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - residual = hidden_states # Self Attention @@ -742,7 +679,6 @@ def forward( output_attentions=None, output_hidden_states=None, return_dict=None, - **kwargs, ): r""" Args: @@ -779,21 +715,6 @@ def forward( return_dict (`bool`, *optional*): Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. """ - position_embeddings = kwargs.pop("position_embeddings", None) - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions output_hidden_states = ( output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states diff --git a/src/transformers/models/mistral/modeling_mistral.py b/src/transformers/models/mistral/modeling_mistral.py index 665e95a8fd7856..ccfa034ae69137 100644 --- a/src/transformers/models/mistral/modeling_mistral.py +++ b/src/transformers/models/mistral/modeling_mistral.py @@ -20,7 +20,6 @@ """ PyTorch Mistral model.""" import inspect import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -246,12 +245,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -344,15 +338,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - - # overwrite attention_mask with padding_mask - attention_mask = kwargs.pop("padding_mask") bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -729,12 +715,7 @@ def forward( past_key_value: Optional[Tuple[torch.Tensor]] = None, output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) """ Args: hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)` diff --git a/src/transformers/models/mixtral/modeling_mixtral.py b/src/transformers/models/mixtral/modeling_mixtral.py index e5a81c4c9083ed..19e4f157189da2 100644 --- a/src/transformers/models/mixtral/modeling_mixtral.py +++ b/src/transformers/models/mixtral/modeling_mixtral.py @@ -20,7 +20,6 @@ """ PyTorch Mixtral model.""" import inspect import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -323,12 +322,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -422,15 +416,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - - # overwrite attention_mask with padding_mask - attention_mask = kwargs.pop("padding_mask") bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -805,14 +791,6 @@ def forward(self, hidden_states): return current_hidden_states -class MixtralBLockSparseTop2MLP(MixtralBlockSparseTop2MLP): - def __init__(self, *args, **kwargs): - logger.warning_once( - "MixtralBLockSparseTop2MLP is deprecated by MixtralBlockSparseTop2MLP and will be removed in v4.40." - ) - super().__init__(*args, **kwargs) - - class MixtralSparseMoeBlock(nn.Module): """ This implementation is @@ -901,12 +879,7 @@ def forward( output_attentions: Optional[bool] = False, output_router_logits: Optional[bool] = False, use_cache: Optional[bool] = False, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) """ Args: hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)` diff --git a/src/transformers/models/olmo/modeling_olmo.py b/src/transformers/models/olmo/modeling_olmo.py index 5f04ce61ba2477..8bfa3dc60626a9 100644 --- a/src/transformers/models/olmo/modeling_olmo.py +++ b/src/transformers/models/olmo/modeling_olmo.py @@ -20,7 +20,6 @@ """PyTorch OLMo model.""" import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -101,29 +100,6 @@ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, s self.register_buffer("inv_freq", inv_freq, persistent=False) # For BC we register cos and sin cached self.max_seq_len_cached = max_position_embeddings - t = torch.arange(self.max_seq_len_cached, device=device, dtype=torch.int64).type_as(self.inv_freq) - t = t / self.scaling_factor - freqs = torch.outer(t, self.inv_freq) - # Different from paper, but it uses a different permutation in order to obtain the same calculation - emb = torch.cat((freqs, freqs), dim=-1) - self.register_buffer("_cos_cached", emb.cos().to(torch.get_default_dtype()), persistent=False) - self.register_buffer("_sin_cached", emb.sin().to(torch.get_default_dtype()), persistent=False) - - @property - def sin_cached(self): - logger.warning_once( - "The sin_cached attribute will be removed in 4.39. Bear in mind that its contents changed in v4.38. Use " - "the forward method of RoPE from now on instead. It is not used in the `OlmoAttention` class" - ) - return self._sin_cached - - @property - def cos_cached(self): - logger.warning_once( - "The cos_cached attribute will be removed in 4.39. Bear in mind that its contents changed in v4.38. Use " - "the forward method of RoPE from now on instead. It is not used in the `OlmoAttention` class" - ) - return self._cos_cached @torch.no_grad() def forward(self, x, position_ids): @@ -690,7 +666,6 @@ def forward( output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, cache_position: Optional[torch.LongTensor] = None, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: """ Args: @@ -706,11 +681,6 @@ def forward( (see `past_key_values`). past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states """ - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - residual = hidden_states hidden_states = self.input_layernorm(hidden_states) @@ -724,7 +694,6 @@ def forward( output_attentions=output_attentions, use_cache=use_cache, cache_position=cache_position, - **kwargs, ) hidden_states = residual + hidden_states diff --git a/src/transformers/models/owlv2/modeling_owlv2.py b/src/transformers/models/owlv2/modeling_owlv2.py index 6e12f5c4d59127..c98846ea699a7f 100644 --- a/src/transformers/models/owlv2/modeling_owlv2.py +++ b/src/transformers/models/owlv2/modeling_owlv2.py @@ -14,7 +14,6 @@ # limitations under the License. """ PyTorch OWLv2 model.""" -import warnings from dataclasses import dataclass from functools import lru_cache from typing import Any, Dict, Optional, Tuple, Union @@ -1197,16 +1196,7 @@ def forward( if return_loss: loss = owlv2_loss(logits_per_text) - if return_base_image_embeds: - warnings.warn( - "`return_base_image_embeds` is deprecated and will be removed in v4.27 of Transformers, one can" - " obtain the base (unprojected) image embeddings from outputs.vision_model_output.", - FutureWarning, - ) - last_hidden_state = vision_outputs[0] - image_embeds = self.vision_model.post_layernorm(last_hidden_state) - else: - text_embeds = text_embeds_norm + text_embeds = text_embeds_norm if not return_dict: output = (logits_per_image, logits_per_text, text_embeds, image_embeds, text_outputs, vision_outputs) diff --git a/src/transformers/models/owlvit/modeling_owlvit.py b/src/transformers/models/owlvit/modeling_owlvit.py index 8d0673341c6f71..c0676f519e2e36 100644 --- a/src/transformers/models/owlvit/modeling_owlvit.py +++ b/src/transformers/models/owlvit/modeling_owlvit.py @@ -14,7 +14,6 @@ # limitations under the License. """ PyTorch OWL-ViT model.""" -import warnings from dataclasses import dataclass from functools import lru_cache from typing import Any, Dict, Optional, Tuple, Union @@ -1180,16 +1179,7 @@ def forward( if return_loss: loss = owlvit_loss(logits_per_text) - if return_base_image_embeds: - warnings.warn( - "`return_base_image_embeds` is deprecated and will be removed in v4.27 of Transformers, one can" - " obtain the base (unprojected) image embeddings from outputs.vision_model_output.", - FutureWarning, - ) - last_hidden_state = vision_outputs[0] - image_embeds = self.vision_model.post_layernorm(last_hidden_state) - else: - text_embeds = text_embeds_norm + text_embeds = text_embeds_norm if not return_dict: output = (logits_per_image, logits_per_text, text_embeds, image_embeds, text_outputs, vision_outputs) diff --git a/src/transformers/models/phi3/modeling_phi3.py b/src/transformers/models/phi3/modeling_phi3.py index 71fcddb4644943..41765632b5ec27 100644 --- a/src/transformers/models/phi3/modeling_phi3.py +++ b/src/transformers/models/phi3/modeling_phi3.py @@ -17,7 +17,6 @@ import inspect import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -430,7 +429,6 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: # Phi3FlashAttention2 attention does not support output_attentions @@ -442,14 +440,6 @@ def forward( output_attentions = False - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - - # overwrite attention_mask with padding_mask - attention_mask = kwargs.pop("padding_mask") - bsz, q_len, _ = hidden_states.size() qkv = self.qkv_proj(hidden_states) @@ -835,12 +825,7 @@ def forward( past_key_value: Optional[Tuple[torch.Tensor]] = None, output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) """ Args: hidden_states (`torch.FloatTensor`): diff --git a/src/transformers/models/qwen2/modeling_qwen2.py b/src/transformers/models/qwen2/modeling_qwen2.py index b5a1370ae1fc8f..76b975ce9b8c3b 100644 --- a/src/transformers/models/qwen2/modeling_qwen2.py +++ b/src/transformers/models/qwen2/modeling_qwen2.py @@ -20,7 +20,6 @@ """ PyTorch Qwen2 model.""" import inspect import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -244,12 +243,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -344,15 +338,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - - # overwrite attention_mask with padding_mask - attention_mask = kwargs.pop("padding_mask") bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -739,13 +725,7 @@ def forward( past_key_value: Optional[Tuple[torch.Tensor]] = None, output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. " - "Please make sure use `attention_mask` instead.`" - ) """ Args: hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)` diff --git a/src/transformers/models/qwen2_moe/modeling_qwen2_moe.py b/src/transformers/models/qwen2_moe/modeling_qwen2_moe.py index 838425505b3b1a..914a2dbdf4216f 100644 --- a/src/transformers/models/qwen2_moe/modeling_qwen2_moe.py +++ b/src/transformers/models/qwen2_moe/modeling_qwen2_moe.py @@ -21,7 +21,6 @@ import inspect import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -321,12 +320,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -422,15 +416,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - - # overwrite attention_mask with padding_mask - attention_mask = kwargs.pop("padding_mask") bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -881,13 +867,7 @@ def forward( output_attentions: Optional[bool] = False, output_router_logits: Optional[bool] = False, use_cache: Optional[bool] = False, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. " - "Please make sure use `attention_mask` instead.`" - ) """ Args: hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)` diff --git a/src/transformers/models/sew_d/configuration_sew_d.py b/src/transformers/models/sew_d/configuration_sew_d.py index aa4b60edc7e059..7a38815b470490 100644 --- a/src/transformers/models/sew_d/configuration_sew_d.py +++ b/src/transformers/models/sew_d/configuration_sew_d.py @@ -279,11 +279,6 @@ def __init__( def inputs_to_logits_ratio(self): return functools.reduce(operator.mul, self.conv_stride, 1) - @property - def hidden_dropout(self): - logger.warning_once("hidden_dropout is not used by the model and will be removed as config attribute in v4.35") - return self._hidden_dropout - def to_dict(self): """ Serializes this instance to a Python dictionary. diff --git a/src/transformers/models/starcoder2/modeling_starcoder2.py b/src/transformers/models/starcoder2/modeling_starcoder2.py index 61e8518d659cae..24d285e0b36af9 100644 --- a/src/transformers/models/starcoder2/modeling_starcoder2.py +++ b/src/transformers/models/starcoder2/modeling_starcoder2.py @@ -20,7 +20,6 @@ """ PyTorch Starcoder2 model.""" import inspect import math -import warnings from typing import List, Optional, Tuple, Union import torch @@ -227,12 +226,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -328,15 +322,7 @@ def forward( past_key_value: Optional[Cache] = None, output_attentions: bool = False, use_cache: bool = False, - **kwargs, ): - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) - - # overwrite attention_mask with padding_mask - attention_mask = kwargs.pop("padding_mask") bsz, q_len, _ = hidden_states.size() query_states = self.q_proj(hidden_states) @@ -717,12 +703,7 @@ def forward( past_key_value: Optional[Tuple[torch.Tensor]] = None, output_attentions: Optional[bool] = False, use_cache: Optional[bool] = False, - **kwargs, ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]: - if "padding_mask" in kwargs: - warnings.warn( - "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`" - ) """ Args: hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)` diff --git a/src/transformers/models/table_transformer/modeling_table_transformer.py b/src/transformers/models/table_transformer/modeling_table_transformer.py index 73d6a73398fbee..3bfdde89079285 100644 --- a/src/transformers/models/table_transformer/modeling_table_transformer.py +++ b/src/transformers/models/table_transformer/modeling_table_transformer.py @@ -461,23 +461,7 @@ def __init__( def _shape(self, tensor: torch.Tensor, seq_len: int, batch_size: int): return tensor.view(batch_size, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous() - def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor], **kwargs): - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - + def with_pos_embed(self, tensor: torch.Tensor, object_queries: Optional[Tensor]): return tensor if object_queries is None else tensor + object_queries def forward( @@ -488,38 +472,8 @@ def forward( key_value_states: Optional[torch.Tensor] = None, spatial_position_embeddings: Optional[torch.Tensor] = None, output_attentions: bool = False, - **kwargs, ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]: """Input shape: Batch x Time x Channel""" - - position_embeddings = kwargs.pop("position_ebmeddings", None) - key_value_position_embeddings = kwargs.pop("key_value_position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if key_value_position_embeddings is not None and spatial_position_embeddings is not None: - raise ValueError( - "Cannot specify both key_value_position_embeddings and spatial_position_embeddings. Please use just spatial_position_embeddings" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - - if key_value_position_embeddings is not None: - logger.warning_once( - "key_value_position_embeddings has been deprecated and will be removed in v4.34. Please use spatial_position_embeddings instead" - ) - spatial_position_embeddings = key_value_position_embeddings - # if key_value_states are provided this layer is used as a cross-attention layer # for the decoder is_cross_attention = key_value_states is not None @@ -1020,7 +974,6 @@ def forward( output_attentions=None, output_hidden_states=None, return_dict=None, - **kwargs, ): r""" Args: @@ -1058,22 +1011,6 @@ def forward( return_dict (`bool`, *optional*): Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. """ - position_embeddings = kwargs.pop("position_embeddings", None) - - if kwargs: - raise ValueError(f"Unexpected arguments {kwargs.keys()}") - - if position_embeddings is not None and object_queries is not None: - raise ValueError( - "Cannot specify both position_embeddings and object_queries. Please use just object_queries" - ) - - if position_embeddings is not None: - logger.warning_once( - "position_embeddings has been deprecated and will be removed in v4.34. Please use object_queries instead" - ) - object_queries = position_embeddings - output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions output_hidden_states = ( output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index b74819c7a1c91b..1c35fc291226ce 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -820,31 +820,6 @@ def prepare_annotation( raise ValueError(f"Format {format} is not supported.") return target - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare - def prepare(self, image, target, return_segmentation_masks=None, masks_path=None): - logger.warning_once( - "The `prepare` method is deprecated and will be removed in a v4.33. " - "Please use `prepare_annotation` instead. Note: the `prepare_annotation` method " - "does not return the image anymore.", - ) - target = self.prepare_annotation(image, target, return_segmentation_masks, masks_path, self.format) - return image, target - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.convert_coco_poly_to_mask - def convert_coco_poly_to_mask(self, *args, **kwargs): - logger.warning_once("The `convert_coco_poly_to_mask` method is deprecated and will be removed in v4.33. ") - return convert_coco_poly_to_mask(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_detection with DETR->Yolos - def prepare_coco_detection(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_detection` method is deprecated and will be removed in v4.33. ") - return prepare_coco_detection_annotation(*args, **kwargs) - - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.prepare_coco_panoptic - def prepare_coco_panoptic(self, *args, **kwargs): - logger.warning_once("The `prepare_coco_panoptic` method is deprecated and will be removed in v4.33. ") - return prepare_coco_panoptic_annotation(*args, **kwargs) - # Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.resize def resize( self,