Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback): cannot import name 'gather_traceback' from 'torch._C._profiler' (unknown location) #1490
import pickle
import torch
import torch.nn as nn
import torch.nn.functional as F
SEED = 1024
torch.manual_seed(SEED)
torch.cuda.manual_seed(SEED)
torch.backends.cudnn.deterministic = True
from torch.utils.data import TensorDataset, DataLoader, Dataset, RandomSampler, SequentialSampler
import torchtext
from torchtext import data
import transformers
from transformers import BertTokenizer, BertModel, BertConfig
from sklearn.metrics import hamming_loss, jaccard_score, label_ranking_average_precision_score, f1_score
from tqdm._tqdm_notebook import tqdm_notebook as tqdm
RuntimeError: Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback):
cannot import name 'gather_traceback' from 'torch._C._profiler' (unknown location)
import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt %matplotlib inline
from wordcloud import WordCloud import re import unicodedata import nltk import csv import string !pip3 install textblob from textblob import TextBlob from nltk.corpus import stopwords !pip3 install demoji nltk.download('all') import demoji !pip3 install -q transformers
!pip3 install torch --upgrade !pip3 install torchtext==0.6.0
import pickle import torch import torch.nn as nn import torch.nn.functional as F SEED = 1024 torch.manual_seed(SEED) torch.cuda.manual_seed(SEED) torch.backends.cudnn.deterministic = True
from torch.utils.data import TensorDataset, DataLoader, Dataset, RandomSampler, SequentialSampler import torchtext from torchtext import data
import transformers from transformers import BertTokenizer, BertModel, BertConfig
import warnings warnings.filterwarnings('ignore') import operator
from sklearn.metrics import hamming_loss, jaccard_score, label_ranking_average_precision_score, f1_score from tqdm._tqdm_notebook import tqdm_notebook as tqdm
ImportError Traceback (most recent call last) File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/utils/import_utils.py:1099, in _LazyModule._get_module(self, module_name) 1098 try: -> 1099 return importlib.import_module("." + module_name, self.name) 1100 except Exception as e:
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/init.py:126, in import_module(name, package) 125 level += 1 --> 126 return _bootstrap._gcd_import(name[level:], package, level)
File :1204, in _gcd_import(name, package, level)
File :1176, in _find_andload(name, import)
File :1147, in _find_and_loadunlocked(name, import)
File :690, in _load_unlocked(spec)
File :940, in exec_module(self, module)
File :241, in _call_with_frames_removed(f, *args, **kwds)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py:26 25 import torch ... 1103 f" traceback):\n{e}" 1104 ) from e
RuntimeError: Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback): cannot import name 'gather_traceback' from 'torch._C._profiler' (unknown location)
Someone please help me