From 783a61699962f4b058688db21d417e1932423417 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 21 Dec 2019 21:54:07 +0100 Subject: [PATCH] Fix F401 flake8 warning (x88 / 116). This change is mostly autogenerated with: $ python -m autoflake --in-place --recursive --remove-all-unused-imports --ignore-init-module-imports examples templates transformers utils hubconf.py setup.py I made minor changes in the generated diff. --- examples/distillation/distiller.py | 3 +-- examples/distillation/scripts/extract.py | 2 +- .../distillation/scripts/extract_distilbert.py | 2 +- examples/run_bertology.py | 3 +-- examples/run_squad.py | 2 +- examples/run_tf_ner.py | 1 - .../adding_a_new_model/configuration_xxx.py | 2 -- templates/adding_a_new_model/modeling_tf_xxx.py | 2 -- templates/adding_a_new_model/modeling_xxx.py | 3 +-- .../tests/modeling_tf_xxx_test.py | 1 - templates/adding_a_new_model/tokenization_xxx.py | 1 - transformers/commands/convert.py | 1 - transformers/configuration_t5.py | 2 -- .../convert_pytorch_checkpoint_to_tf2.py | 2 -- ...rta_original_pytorch_checkpoint_to_pytorch.py | 1 - transformers/data/metrics/squad_metrics.py | 4 +--- transformers/data/processors/squad.py | 4 ++-- transformers/hf_api.py | 1 - transformers/modeling_auto.py | 2 -- transformers/modeling_ctrl.py | 3 +-- transformers/modeling_distilbert.py | 1 - transformers/modeling_encoder_decoder.py | 1 - transformers/modeling_gpt2.py | 2 -- transformers/modeling_openai.py | 1 - transformers/modeling_t5.py | 2 +- transformers/modeling_tf_auto.py | 1 - transformers/modeling_tf_ctrl.py | 2 +- transformers/modeling_tf_distilbert.py | 1 - transformers/modeling_tf_pytorch_utils.py | 16 ++++++++-------- transformers/modeling_tf_roberta.py | 2 +- transformers/modeling_tf_transfo_xl.py | 3 +-- transformers/modeling_tf_transfo_xl_utilities.py | 1 - transformers/modeling_transfo_xl.py | 4 +--- transformers/modeling_transfo_xl_utilities.py | 1 - transformers/modeling_utils.py | 1 - transformers/pipelines.py | 1 - transformers/tests/modeling_auto_test.py | 3 --- transformers/tests/modeling_distilbert_test.py | 2 +- transformers/tests/modeling_t5_test.py | 4 ++-- transformers/tests/modeling_tf_albert_test.py | 1 - transformers/tests/modeling_tf_auto_test.py | 4 ---- transformers/tests/modeling_tf_common_test.py | 3 +-- transformers/tests/modeling_tf_ctrl_test.py | 1 - .../tests/modeling_tf_distilbert_test.py | 3 +-- transformers/tests/modeling_tf_t5_test.py | 3 +-- transformers/tests/tokenization_albert_test.py | 2 +- .../tests/tokenization_distilbert_test.py | 1 - .../tests/tokenization_transfo_xl_test.py | 1 - transformers/tokenization_bert_japanese.py | 1 - transformers/tokenization_distilbert.py | 1 - transformers/tokenization_roberta.py | 2 -- transformers/tokenization_xlm.py | 1 - 52 files changed, 30 insertions(+), 85 deletions(-) diff --git a/examples/distillation/distiller.py b/examples/distillation/distiller.py index 16d73ece3c..c43f13de0c 100644 --- a/examples/distillation/distiller.py +++ b/examples/distillation/distiller.py @@ -19,14 +19,13 @@ import math import os import time -import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.optim import AdamW from torch.utils.data import BatchSampler, DataLoader, RandomSampler from torch.utils.data.distributed import DistributedSampler -from tqdm import tqdm, trange +from tqdm import tqdm import psutil from grouped_batch_sampler import GroupedBatchSampler, create_lengths_groups diff --git a/examples/distillation/scripts/extract.py b/examples/distillation/scripts/extract.py index f91b6d321f..8d102c0cda 100644 --- a/examples/distillation/scripts/extract.py +++ b/examples/distillation/scripts/extract.py @@ -20,7 +20,7 @@ import argparse import torch -from transformers import BertForMaskedLM, GPT2LMHeadModel, RobertaForMaskedLM +from transformers import GPT2LMHeadModel, RobertaForMaskedLM if __name__ == "__main__": diff --git a/examples/distillation/scripts/extract_distilbert.py b/examples/distillation/scripts/extract_distilbert.py index db0dc3ed84..972418b56b 100644 --- a/examples/distillation/scripts/extract_distilbert.py +++ b/examples/distillation/scripts/extract_distilbert.py @@ -20,7 +20,7 @@ import argparse import torch -from transformers import BertForMaskedLM, RobertaForMaskedLM +from transformers import BertForMaskedLM if __name__ == "__main__": diff --git a/examples/run_bertology.py b/examples/run_bertology.py index 184e6a2e3c..6d69477fc3 100644 --- a/examples/run_bertology.py +++ b/examples/run_bertology.py @@ -26,8 +26,7 @@ from datetime import datetime import numpy as np import torch -from torch.nn import CrossEntropyLoss, MSELoss -from torch.utils.data import DataLoader, SequentialSampler, Subset, TensorDataset +from torch.utils.data import DataLoader, SequentialSampler, Subset from torch.utils.data.distributed import DistributedSampler from tqdm import tqdm diff --git a/examples/run_squad.py b/examples/run_squad.py index acf4d0eecd..6495d29721 100644 --- a/examples/run_squad.py +++ b/examples/run_squad.py @@ -26,7 +26,7 @@ import timeit import numpy as np import torch -from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset +from torch.utils.data import DataLoader, RandomSampler, SequentialSampler from torch.utils.data.distributed import DistributedSampler from tqdm import tqdm, trange diff --git a/examples/run_tf_ner.py b/examples/run_tf_ner.py index 68c4b15a06..c360f9e778 100644 --- a/examples/run_tf_ner.py +++ b/examples/run_tf_ner.py @@ -1,5 +1,4 @@ # coding=utf-8 -import _pickle as pickle import collections import datetime import glob diff --git a/templates/adding_a_new_model/configuration_xxx.py b/templates/adding_a_new_model/configuration_xxx.py index 226f8a1d84..f2feb7360e 100644 --- a/templates/adding_a_new_model/configuration_xxx.py +++ b/templates/adding_a_new_model/configuration_xxx.py @@ -18,8 +18,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera import logging -import six - from .configuration_utils import PretrainedConfig diff --git a/templates/adding_a_new_model/modeling_tf_xxx.py b/templates/adding_a_new_model/modeling_tf_xxx.py index c352625a8c..df64c19220 100644 --- a/templates/adding_a_new_model/modeling_tf_xxx.py +++ b/templates/adding_a_new_model/modeling_tf_xxx.py @@ -21,10 +21,8 @@ from __future__ import absolute_import, division, print_function, unicode_literals -import itertools import logging -import numpy as np import tensorflow as tf from .configuration_xxx import XxxConfig diff --git a/templates/adding_a_new_model/modeling_xxx.py b/templates/adding_a_new_model/modeling_xxx.py index abf58844dd..6db97df1bf 100644 --- a/templates/adding_a_new_model/modeling_xxx.py +++ b/templates/adding_a_new_model/modeling_xxx.py @@ -20,7 +20,6 @@ from __future__ import absolute_import, division, print_function, unicode_literals -import itertools import logging import os @@ -30,7 +29,7 @@ from torch.nn import CrossEntropyLoss, MSELoss from .configuration_xxx import XxxConfig from .file_utils import add_start_docstrings -from .modeling_utils import PreTrainedModel, prune_linear_layer +from .modeling_utils import PreTrainedModel logger = logging.getLogger(__name__) diff --git a/templates/adding_a_new_model/tests/modeling_tf_xxx_test.py b/templates/adding_a_new_model/tests/modeling_tf_xxx_test.py index 126a9eb05f..844f538b77 100644 --- a/templates/adding_a_new_model/tests/modeling_tf_xxx_test.py +++ b/templates/adding_a_new_model/tests/modeling_tf_xxx_test.py @@ -24,7 +24,6 @@ from .utils import CACHE_DIR, require_tf, slow if is_tf_available(): - import tensorflow as tf from transformers.modeling_tf_xxx import ( TFXxxModel, TFXxxForMaskedLM, diff --git a/templates/adding_a_new_model/tokenization_xxx.py b/templates/adding_a_new_model/tokenization_xxx.py index 30e3ce5674..690815b970 100644 --- a/templates/adding_a_new_model/tokenization_xxx.py +++ b/templates/adding_a_new_model/tokenization_xxx.py @@ -19,7 +19,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera import collections import logging import os -import unicodedata from io import open from .tokenization_utils import PreTrainedTokenizer diff --git a/transformers/commands/convert.py b/transformers/commands/convert.py index 29b6b1076b..a858e13dd6 100644 --- a/transformers/commands/convert.py +++ b/transformers/commands/convert.py @@ -1,7 +1,6 @@ from argparse import ArgumentParser, Namespace from logging import getLogger -from transformers import AutoModel, AutoTokenizer from transformers.commands import BaseTransformersCLICommand diff --git a/transformers/configuration_t5.py b/transformers/configuration_t5.py index e0f1dedd7a..9ba1ada6d0 100644 --- a/transformers/configuration_t5.py +++ b/transformers/configuration_t5.py @@ -18,8 +18,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera import logging -import six - from .configuration_utils import PretrainedConfig diff --git a/transformers/convert_pytorch_checkpoint_to_tf2.py b/transformers/convert_pytorch_checkpoint_to_tf2.py index 6494814309..54ffddbe9a 100644 --- a/transformers/convert_pytorch_checkpoint_to_tf2.py +++ b/transformers/convert_pytorch_checkpoint_to_tf2.py @@ -20,8 +20,6 @@ import argparse import logging import os -import tensorflow as tf - from transformers import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, diff --git a/transformers/convert_roberta_original_pytorch_checkpoint_to_pytorch.py b/transformers/convert_roberta_original_pytorch_checkpoint_to_pytorch.py index 9044bc5926..283370fc35 100644 --- a/transformers/convert_roberta_original_pytorch_checkpoint_to_pytorch.py +++ b/transformers/convert_roberta_original_pytorch_checkpoint_to_pytorch.py @@ -20,7 +20,6 @@ import argparse import logging import pathlib -import numpy as np import torch from packaging import version diff --git a/transformers/data/metrics/squad_metrics.py b/transformers/data/metrics/squad_metrics.py index 0009a2e70f..2b9778bcdd 100644 --- a/transformers/data/metrics/squad_metrics.py +++ b/transformers/data/metrics/squad_metrics.py @@ -16,9 +16,7 @@ import re import string from io import open -from tqdm import tqdm - -from transformers.tokenization_bert import BasicTokenizer, whitespace_tokenize +from transformers.tokenization_bert import BasicTokenizer logger = logging.getLogger(__name__) diff --git a/transformers/data/processors/squad.py b/transformers/data/processors/squad.py index 9c1c3edfed..8df4547c5f 100644 --- a/transformers/data/processors/squad.py +++ b/transformers/data/processors/squad.py @@ -8,8 +8,8 @@ import numpy as np from tqdm import tqdm from ...file_utils import is_tf_available, is_torch_available -from ...tokenization_bert import BasicTokenizer, whitespace_tokenize -from .utils import DataProcessor, InputExample, InputFeatures +from ...tokenization_bert import whitespace_tokenize +from .utils import DataProcessor if is_torch_available(): diff --git a/transformers/hf_api.py b/transformers/hf_api.py index 13469728dc..9e287bd5b3 100644 --- a/transformers/hf_api.py +++ b/transformers/hf_api.py @@ -21,7 +21,6 @@ from typing import List import requests import six -from requests.exceptions import HTTPError from tqdm import tqdm diff --git a/transformers/modeling_auto.py b/transformers/modeling_auto.py index 2df74130e8..f5f8ed2049 100644 --- a/transformers/modeling_auto.py +++ b/transformers/modeling_auto.py @@ -32,7 +32,6 @@ from .configuration_auto import ( XLMRobertaConfig, XLNetConfig, ) -from .file_utils import add_start_docstrings from .modeling_albert import ( ALBERT_PRETRAINED_MODEL_ARCHIVE_MAP, AlbertForMaskedLM, @@ -76,7 +75,6 @@ from .modeling_roberta import ( ) from .modeling_t5 import T5_PRETRAINED_MODEL_ARCHIVE_MAP, T5Model, T5WithLMHeadModel from .modeling_transfo_xl import TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_MAP, TransfoXLLMHeadModel, TransfoXLModel -from .modeling_utils import PreTrainedModel, SequenceSummary from .modeling_xlm import ( XLM_PRETRAINED_MODEL_ARCHIVE_MAP, XLMForQuestionAnswering, diff --git a/transformers/modeling_ctrl.py b/transformers/modeling_ctrl.py index ed7a5bcc0e..9cd1ad7313 100644 --- a/transformers/modeling_ctrl.py +++ b/transformers/modeling_ctrl.py @@ -23,11 +23,10 @@ import numpy as np import torch import torch.nn as nn from torch.nn import CrossEntropyLoss -from torch.nn.parameter import Parameter from .configuration_ctrl import CTRLConfig from .file_utils import add_start_docstrings -from .modeling_utils import Conv1D, PreTrainedModel, SequenceSummary, prune_conv1d_layer +from .modeling_utils import Conv1D, PreTrainedModel logger = logging.getLogger(__name__) diff --git a/transformers/modeling_distilbert.py b/transformers/modeling_distilbert.py index 943a759233..1c6cef1b33 100644 --- a/transformers/modeling_distilbert.py +++ b/transformers/modeling_distilbert.py @@ -19,7 +19,6 @@ from __future__ import absolute_import, division, print_function, unicode_literals import copy -import itertools import logging import math diff --git a/transformers/modeling_encoder_decoder.py b/transformers/modeling_encoder_decoder.py index 65bbb4bbd3..ec90dc7e45 100644 --- a/transformers/modeling_encoder_decoder.py +++ b/transformers/modeling_encoder_decoder.py @@ -21,7 +21,6 @@ import os import torch from torch import nn -from tqdm import trange from .modeling_auto import AutoModel, AutoModelWithLMHead diff --git a/transformers/modeling_gpt2.py b/transformers/modeling_gpt2.py index 67fc2c9d9a..15ae12c15d 100644 --- a/transformers/modeling_gpt2.py +++ b/transformers/modeling_gpt2.py @@ -24,7 +24,6 @@ import os import torch import torch.nn as nn from torch.nn import CrossEntropyLoss -from torch.nn.parameter import Parameter from .configuration_gpt2 import GPT2Config from .file_utils import add_start_docstrings @@ -47,7 +46,6 @@ def load_tf_weights_in_gpt2(model, config, gpt2_checkpoint_path): """ try: import re - import numpy as np import tensorflow as tf except ImportError: logger.error( diff --git a/transformers/modeling_openai.py b/transformers/modeling_openai.py index a3b9c74e19..c3dec01092 100644 --- a/transformers/modeling_openai.py +++ b/transformers/modeling_openai.py @@ -26,7 +26,6 @@ from io import open import torch import torch.nn as nn from torch.nn import CrossEntropyLoss -from torch.nn.parameter import Parameter from .configuration_openai import OpenAIGPTConfig from .file_utils import add_start_docstrings diff --git a/transformers/modeling_t5.py b/transformers/modeling_t5.py index 2061f6ce76..5c2cd403f1 100644 --- a/transformers/modeling_t5.py +++ b/transformers/modeling_t5.py @@ -25,7 +25,7 @@ import os import torch import torch.nn.functional as F from torch import nn -from torch.nn import CrossEntropyLoss, MSELoss +from torch.nn import CrossEntropyLoss from .configuration_t5 import T5Config from .file_utils import DUMMY_INPUTS, DUMMY_MASK, add_start_docstrings diff --git a/transformers/modeling_tf_auto.py b/transformers/modeling_tf_auto.py index bd41893b68..e34f417a6b 100644 --- a/transformers/modeling_tf_auto.py +++ b/transformers/modeling_tf_auto.py @@ -29,7 +29,6 @@ from .configuration_auto import ( XLMConfig, XLNetConfig, ) -from .file_utils import add_start_docstrings from .modeling_tf_albert import ( TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_MAP, TFAlbertForMaskedLM, diff --git a/transformers/modeling_tf_ctrl.py b/transformers/modeling_tf_ctrl.py index 2f791b69f0..5b73fb1930 100644 --- a/transformers/modeling_tf_ctrl.py +++ b/transformers/modeling_tf_ctrl.py @@ -24,7 +24,7 @@ import tensorflow as tf from .configuration_ctrl import CTRLConfig from .file_utils import add_start_docstrings -from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings, get_initializer, shape_list +from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings, shape_list logger = logging.getLogger(__name__) diff --git a/transformers/modeling_tf_distilbert.py b/transformers/modeling_tf_distilbert.py index b5fa934a6f..95a5ec0361 100644 --- a/transformers/modeling_tf_distilbert.py +++ b/transformers/modeling_tf_distilbert.py @@ -16,7 +16,6 @@ """ from __future__ import absolute_import, division, print_function, unicode_literals -import itertools import logging import math diff --git a/transformers/modeling_tf_pytorch_utils.py b/transformers/modeling_tf_pytorch_utils.py index 92ff8bf21b..3882cd3c43 100644 --- a/transformers/modeling_tf_pytorch_utils.py +++ b/transformers/modeling_tf_pytorch_utils.py @@ -75,8 +75,8 @@ def load_pytorch_checkpoint_in_tf2_model(tf_model, pytorch_checkpoint_path, tf_i """ Load pytorch checkpoints in a TF 2.0 model """ try: - import tensorflow as tf - import torch + import tensorflow as tf # noqa: F401 + import torch # noqa: F401 except ImportError as e: logger.error( "Loading a PyTorch model in TensorFlow, requires both PyTorch and TensorFlow to be installed. Please see " @@ -109,8 +109,8 @@ def load_pytorch_weights_in_tf2_model(tf_model, pt_state_dict, tf_inputs=None, a """ Load pytorch state_dict in a TF 2.0 model. """ try: - import torch - import tensorflow as tf + import torch # noqa: F401 + import tensorflow as tf # noqa: F401 from tensorflow.python.keras import backend as K except ImportError as e: logger.error( @@ -208,8 +208,8 @@ def load_tf2_checkpoint_in_pytorch_model(pt_model, tf_checkpoint_path, tf_inputs (see https://github.com/tensorflow/tensorflow/blob/ee16fcac960ae660e0e4496658a366e2f745e1f0/tensorflow/python/keras/engine/network.py#L1352-L1357). """ try: - import tensorflow as tf - import torch + import tensorflow as tf # noqa: F401 + import torch # noqa: F401 except ImportError as e: logger.error( "Loading a TensorFlow model in PyTorch, requires both PyTorch and TensorFlow to be installed. Please see " @@ -250,8 +250,8 @@ def load_tf2_weights_in_pytorch_model(pt_model, tf_weights, allow_missing_keys=F """ Load TF2.0 symbolic weights in a PyTorch model """ try: - import tensorflow as tf - import torch + import tensorflow as tf # noqa: F401 + import torch # noqa: F401 except ImportError as e: logger.error( "Loading a TensorFlow model in PyTorch, requires both PyTorch and TensorFlow to be installed. Please see " diff --git a/transformers/modeling_tf_roberta.py b/transformers/modeling_tf_roberta.py index 7aca11f5bf..9ad93c0b57 100644 --- a/transformers/modeling_tf_roberta.py +++ b/transformers/modeling_tf_roberta.py @@ -23,7 +23,7 @@ import tensorflow as tf from .configuration_roberta import RobertaConfig from .file_utils import add_start_docstrings -from .modeling_tf_bert import TFBertEmbeddings, TFBertMainLayer, gelu, gelu_new +from .modeling_tf_bert import TFBertEmbeddings, TFBertMainLayer, gelu from .modeling_tf_utils import TFPreTrainedModel, get_initializer, shape_list diff --git a/transformers/modeling_tf_transfo_xl.py b/transformers/modeling_tf_transfo_xl.py index a1f972caf8..1f3f7cd559 100644 --- a/transformers/modeling_tf_transfo_xl.py +++ b/transformers/modeling_tf_transfo_xl.py @@ -20,13 +20,12 @@ from __future__ import absolute_import, division, print_function, unicode_litera import logging -import numpy as np import tensorflow as tf from .configuration_transfo_xl import TransfoXLConfig from .file_utils import add_start_docstrings from .modeling_tf_transfo_xl_utilities import TFAdaptiveSoftmaxMask -from .modeling_tf_utils import TFConv1D, TFPreTrainedModel, TFSequenceSummary, get_initializer, shape_list +from .modeling_tf_utils import TFPreTrainedModel, get_initializer, shape_list logger = logging.getLogger(__name__) diff --git a/transformers/modeling_tf_transfo_xl_utilities.py b/transformers/modeling_tf_transfo_xl_utilities.py index dd312c4dab..cd32d86390 100644 --- a/transformers/modeling_tf_transfo_xl_utilities.py +++ b/transformers/modeling_tf_transfo_xl_utilities.py @@ -17,7 +17,6 @@ """ -import numpy as np import tensorflow as tf from .modeling_tf_utils import shape_list diff --git a/transformers/modeling_transfo_xl.py b/transformers/modeling_transfo_xl.py index e9bd1c4893..a6b71538ea 100644 --- a/transformers/modeling_transfo_xl.py +++ b/transformers/modeling_transfo_xl.py @@ -25,13 +25,11 @@ import logging import torch import torch.nn as nn import torch.nn.functional as F -from torch.nn import CrossEntropyLoss -from torch.nn.parameter import Parameter from .configuration_transfo_xl import TransfoXLConfig from .file_utils import add_start_docstrings from .modeling_transfo_xl_utilities import LogUniformSampler, ProjectedAdaptiveLogSoftmax, sample_logits -from .modeling_utils import Conv1D, PreTrainedModel, SequenceSummary, prune_conv1d_layer +from .modeling_utils import PreTrainedModel logger = logging.getLogger(__name__) diff --git a/transformers/modeling_transfo_xl_utilities.py b/transformers/modeling_transfo_xl_utilities.py index 1d600f74e0..63900c7b80 100644 --- a/transformers/modeling_transfo_xl_utilities.py +++ b/transformers/modeling_transfo_xl_utilities.py @@ -18,7 +18,6 @@ """ -import numpy as np import torch import torch.nn as nn import torch.nn.functional as F diff --git a/transformers/modeling_utils.py b/transformers/modeling_utils.py index 2424193622..6fe6fd5322 100644 --- a/transformers/modeling_utils.py +++ b/transformers/modeling_utils.py @@ -20,7 +20,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera import logging import os -import six import torch from torch import nn from torch.nn import CrossEntropyLoss diff --git a/transformers/pipelines.py b/transformers/pipelines.py index 14cb4ac848..1a18de0d96 100755 --- a/transformers/pipelines.py +++ b/transformers/pipelines.py @@ -22,7 +22,6 @@ import pickle import sys from abc import ABC, abstractmethod from contextlib import contextmanager -from itertools import groupby from os.path import abspath, exists from typing import Dict, List, Optional, Tuple, Union diff --git a/transformers/tests/modeling_auto_test.py b/transformers/tests/modeling_auto_test.py index c2deedc2a4..a174dca86a 100644 --- a/transformers/tests/modeling_auto_test.py +++ b/transformers/tests/modeling_auto_test.py @@ -37,9 +37,6 @@ if is_torch_available(): ) from transformers.modeling_bert import BERT_PRETRAINED_MODEL_ARCHIVE_MAP - from .modeling_common_test import CommonTestCases, ids_tensor - from .configuration_common_test import ConfigTester - @require_torch class AutoModelTest(unittest.TestCase): diff --git a/transformers/tests/modeling_distilbert_test.py b/transformers/tests/modeling_distilbert_test.py index eee84af1cb..1044f15ee5 100644 --- a/transformers/tests/modeling_distilbert_test.py +++ b/transformers/tests/modeling_distilbert_test.py @@ -20,7 +20,7 @@ from transformers import is_torch_available from .configuration_common_test import ConfigTester from .modeling_common_test import CommonTestCases, ids_tensor -from .utils import CACHE_DIR, require_torch, slow, torch_device +from .utils import require_torch, torch_device if is_torch_available(): diff --git a/transformers/tests/modeling_t5_test.py b/transformers/tests/modeling_t5_test.py index 2bf3bdae17..460037ea33 100644 --- a/transformers/tests/modeling_t5_test.py +++ b/transformers/tests/modeling_t5_test.py @@ -19,8 +19,8 @@ import unittest from transformers import is_torch_available from .configuration_common_test import ConfigTester -from .modeling_common_test import CommonTestCases, floats_tensor, ids_tensor -from .utils import CACHE_DIR, require_torch, slow, torch_device +from .modeling_common_test import CommonTestCases, ids_tensor +from .utils import CACHE_DIR, require_torch, slow if is_torch_available(): diff --git a/transformers/tests/modeling_tf_albert_test.py b/transformers/tests/modeling_tf_albert_test.py index 342ad65588..a34f4b3813 100644 --- a/transformers/tests/modeling_tf_albert_test.py +++ b/transformers/tests/modeling_tf_albert_test.py @@ -24,7 +24,6 @@ from .utils import CACHE_DIR, require_tf, slow if is_tf_available(): - import tensorflow as tf from transformers.modeling_tf_albert import ( TFAlbertModel, TFAlbertForMaskedLM, diff --git a/transformers/tests/modeling_tf_auto_test.py b/transformers/tests/modeling_tf_auto_test.py index 3530339b63..b06d52ed2d 100644 --- a/transformers/tests/modeling_tf_auto_test.py +++ b/transformers/tests/modeling_tf_auto_test.py @@ -35,10 +35,6 @@ if is_tf_available(): TFAutoModelForQuestionAnswering, TFBertForQuestionAnswering, ) - from transformers.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_MAP - - from .modeling_common_test import CommonTestCases, ids_tensor - from .configuration_common_test import ConfigTester @require_tf diff --git a/transformers/tests/modeling_tf_common_test.py b/transformers/tests/modeling_tf_common_test.py index bd7e6636a3..fb85181a7a 100644 --- a/transformers/tests/modeling_tf_common_test.py +++ b/transformers/tests/modeling_tf_common_test.py @@ -24,13 +24,12 @@ import unittest from transformers import is_tf_available, is_torch_available -from .utils import require_tf, slow +from .utils import require_tf if is_tf_available(): import tensorflow as tf import numpy as np - from transformers import TFPreTrainedModel # from transformers.modeling_bert import BertModel, BertConfig, BERT_PRETRAINED_MODEL_ARCHIVE_MAP diff --git a/transformers/tests/modeling_tf_ctrl_test.py b/transformers/tests/modeling_tf_ctrl_test.py index 41a2da2a4f..dad072cd3b 100644 --- a/transformers/tests/modeling_tf_ctrl_test.py +++ b/transformers/tests/modeling_tf_ctrl_test.py @@ -24,7 +24,6 @@ from .utils import CACHE_DIR, require_tf, slow if is_tf_available(): - import tensorflow as tf from transformers.modeling_tf_ctrl import TFCTRLModel, TFCTRLLMHeadModel, TF_CTRL_PRETRAINED_MODEL_ARCHIVE_MAP diff --git a/transformers/tests/modeling_tf_distilbert_test.py b/transformers/tests/modeling_tf_distilbert_test.py index ebb17e2980..5b343c09a0 100644 --- a/transformers/tests/modeling_tf_distilbert_test.py +++ b/transformers/tests/modeling_tf_distilbert_test.py @@ -20,11 +20,10 @@ from transformers import DistilBertConfig, is_tf_available from .configuration_common_test import ConfigTester from .modeling_tf_common_test import TFCommonTestCases, ids_tensor -from .utils import CACHE_DIR, require_tf, slow +from .utils import require_tf if is_tf_available(): - import tensorflow as tf from transformers.modeling_tf_distilbert import ( TFDistilBertModel, TFDistilBertForMaskedLM, diff --git a/transformers/tests/modeling_tf_t5_test.py b/transformers/tests/modeling_tf_t5_test.py index 9042a763f1..84919bf43c 100644 --- a/transformers/tests/modeling_tf_t5_test.py +++ b/transformers/tests/modeling_tf_t5_test.py @@ -24,8 +24,7 @@ from .utils import CACHE_DIR, require_tf, slow if is_tf_available(): - import tensorflow as tf - from transformers.modeling_tf_t5 import TFT5Model, TFT5WithLMHeadModel, TF_T5_PRETRAINED_MODEL_ARCHIVE_MAP + from transformers.modeling_tf_t5 import TFT5Model, TFT5WithLMHeadModel @require_tf diff --git a/transformers/tests/tokenization_albert_test.py b/transformers/tests/tokenization_albert_test.py index 867dd5591c..88d18031fd 100644 --- a/transformers/tests/tokenization_albert_test.py +++ b/transformers/tests/tokenization_albert_test.py @@ -17,7 +17,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera import os import unittest -from transformers.tokenization_albert import SPIECE_UNDERLINE, AlbertTokenizer +from transformers.tokenization_albert import AlbertTokenizer from .tokenization_tests_commons import CommonTestCases diff --git a/transformers/tests/tokenization_distilbert_test.py b/transformers/tests/tokenization_distilbert_test.py index 916db759c6..3417fc76d5 100644 --- a/transformers/tests/tokenization_distilbert_test.py +++ b/transformers/tests/tokenization_distilbert_test.py @@ -19,7 +19,6 @@ import unittest from transformers.tokenization_distilbert import DistilBertTokenizer from .tokenization_bert_test import BertTokenizationTest -from .tokenization_tests_commons import CommonTestCases from .utils import slow diff --git a/transformers/tests/tokenization_transfo_xl_test.py b/transformers/tests/tokenization_transfo_xl_test.py index cb9d3d4de7..6b1d1dfcec 100644 --- a/transformers/tests/tokenization_transfo_xl_test.py +++ b/transformers/tests/tokenization_transfo_xl_test.py @@ -25,7 +25,6 @@ from .utils import require_torch if is_torch_available(): - import torch from transformers.tokenization_transfo_xl import TransfoXLTokenizer, VOCAB_FILES_NAMES diff --git a/transformers/tokenization_bert_japanese.py b/transformers/tokenization_bert_japanese.py index c17d2a3ee5..439d652bed 100644 --- a/transformers/tokenization_bert_japanese.py +++ b/transformers/tokenization_bert_japanese.py @@ -24,7 +24,6 @@ import unicodedata import six from .tokenization_bert import BasicTokenizer, BertTokenizer, WordpieceTokenizer, load_vocab -from .tokenization_utils import PreTrainedTokenizer logger = logging.getLogger(__name__) diff --git a/transformers/tokenization_distilbert.py b/transformers/tokenization_distilbert.py index 39dee1c3a6..0821c859d8 100644 --- a/transformers/tokenization_distilbert.py +++ b/transformers/tokenization_distilbert.py @@ -17,7 +17,6 @@ from __future__ import absolute_import, division, print_function, unicode_literals import logging -import unicodedata from .tokenization_bert import BertTokenizer diff --git a/transformers/tokenization_roberta.py b/transformers/tokenization_roberta.py index 9b34abfef3..bc1695f238 100644 --- a/transformers/tokenization_roberta.py +++ b/transformers/tokenization_roberta.py @@ -17,8 +17,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera import logging -import regex as re - from .tokenization_gpt2 import GPT2Tokenizer diff --git a/transformers/tokenization_xlm.py b/transformers/tokenization_xlm.py index 9d315f8801..062d2697a0 100644 --- a/transformers/tokenization_xlm.py +++ b/transformers/tokenization_xlm.py @@ -25,7 +25,6 @@ from io import open import sacremoses as sm -from .tokenization_bert import BasicTokenizer from .tokenization_utils import PreTrainedTokenizer