ImportError: cannot import name 'hf_bucket_url' in HuggingFace Transformers

ImportError: cannot import name 'hf_bucket_url' in HuggingFace Transformers

所以我在 Google Colab

上安装了最新版本的变形金刚
!pip install transformers 

尝试使用

调用转换文件时
!python /usr/local/lib/python3.6/dist-packages/transformers/convert_pytorch_checkpoint_to_tf2.py .py --help  

或尝试使用

from transformers.file_utils import hf_bucket_url.                                 // works 
from transformers.convert_pytorch_checkpoint_to_tf2 import *.                      // fails

convert_pytorch_checkpoint_to_tf("gpt2", pytorch_file, config_file, tf_file).      

我收到这个错误

 ImportError                               Traceback (most recent call last)

<ipython-input-3-dadaf83ecea0> in <module>()
      1 from transformers.file_utils import hf_bucket_url
----> 2 from transformers.convert_pytorch_checkpoint_to_tf2 import *
      3 
      4 convert_pytorch_checkpoint_to_tf("gpt2", pytorch_file, config_file, tf_file)
/usr/local/lib/python3.6/dist-packages/transformers/convert_pytorch_checkpoint_to_tf2.py in <module>()
     20 import os
     21 
---> 22 from transformers import (
     23     ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
     24     BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,

ImportError: cannot import name 'hf_bucket_url'

怎么回事?

原来是个bug。 This PR solves the issue 通过正确导入函数 hf_bucket_url