# Buggy code
def embedding_length(self) -> int:
    """Returns the length of the embedding vector."""

    if not self.layer_mean:
        length = len(self.layer_indexes) * self.model.config.hidden_size
    else:
        length = self.model.config.hidden_size

    if self.pooling_operation == "first_last":
        length *= 2

    return length


# Traceback (OSError)
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-2f413379aedd> in <module>
6
7 # load the NER tagger
----> 8 tagger = SequenceTagger.load('best-model.pt')
9
10

c:\users\nicod\miniconda3\lib\site-packages\flair\nn.py in load(cls, model)
86             # see https://github.com/zalandoresearch/flair/issues/351
87             f = file_utils.load_big_file(str(model_file))
---> 88             state = torch.load(f, map_location='cpu')
89
90         model = cls._init_model_with_state_dict(state)

c:\users\nicod\miniconda3\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
527             with _open_zipfile_reader(f) as opened_zipfile:
528                 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
--> 529         return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
530
531

c:\users\nicod\miniconda3\lib\site-packages\torch\serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
700     unpickler = pickle_module.Unpickler(f, **pickle_load_args)
701     unpickler.persistent_load = persistent_load
--> 702     result = unpickler.load()
703
704     deserialized_storage_keys = pickle_module.load(f, **pickle_load_args)

c:\users\nicod\miniconda3\lib\site-packages\transformers\tokenization_camembert.py in __setstate__(self, d)
259             raise
260         self.sp_model = spm.SentencePieceProcessor()
--> 261         self.sp_model.Load(self.vocab_file)
262
263     def convert_tokens_to_string(self, tokens):

c:\users\nicod\miniconda3\lib\site-packages\sentencepiece.py in Load(self, model_file, model_proto)
365       if model_proto:
366         return self.LoadFromSerializedProto(model_proto)
--> 367       return self.LoadFromFile(model_file)
368
369

c:\users\nicod\miniconda3\lib\site-packages\sentencepiece.py in LoadFromFile(self, arg)
175
176     def LoadFromFile(self, arg):
--> 177         return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
178
179     def Init(self,

OSError: Not found: "/home/ubuntu/.cache/torch/transformers/3715e3a4a2de48834619b2a6f48979e13ddff5cabfb1f3409db689f9ce3bb98f.28d30f926f545047fc59da64289371eef0fbdc0764ce9ec56f808a646fcfec59": No such file or directory Error #2

# Fixed code
def embedding_length(self) -> int:
    if "embedding_length_internal" in self.__dict__.keys():
        return self.embedding_length_internal

    # """Returns the length of the embedding vector."""
    if not self.layer_mean:
        length = len(self.layer_indexes) * self.model.config.hidden_size
    else:
        length = self.model.config.hidden_size

    if self.pooling_operation == "first_last":
        length *= 2

    self.__embedding_length = length

    return length