Return the method to load the sub model. In practice, this method will return the `"from_pretrained"` (or `load_method_name`) method of the class object except if loading from a DDUF checkpoint. In that case, transformers models and tokenizers have a specific loading method that we
(class_obj: object, load_method_name: str, is_dduf: bool)
| 936 | |
| 937 | |
| 938 | def _get_load_method(class_obj: object, load_method_name: str, is_dduf: bool) -> Callable: |
| 939 | """ |
| 940 | Return the method to load the sub model. |
| 941 | |
| 942 | In practice, this method will return the `"from_pretrained"` (or `load_method_name`) method of the class object |
| 943 | except if loading from a DDUF checkpoint. In that case, transformers models and tokenizers have a specific loading |
| 944 | method that we need to use. |
| 945 | """ |
| 946 | if is_dduf: |
| 947 | if issubclass(class_obj, PreTrainedTokenizerBase): |
| 948 | return lambda *args, **kwargs: _load_tokenizer_from_dduf(class_obj, *args, **kwargs) |
| 949 | if issubclass(class_obj, PreTrainedModel): |
| 950 | return lambda *args, **kwargs: _load_transformers_model_from_dduf(class_obj, *args, **kwargs) |
| 951 | return getattr(class_obj, load_method_name) |
| 952 | |
| 953 | |
| 954 | def _fetch_class_library_tuple(module): |
no test coverage detected
searching dependent graphs…