General Utilities

This page lists all of Transformers general utility functions that are found in the file file_utils.py.

Most of those are only useful if you are studying the general code in the library.

Enums and namedtuples

class transformers.file_utils.ExplicitEnum(value)[source]

Enum with more explicit error message for missing values.

class transformers.file_utils.PaddingStrategy(value)[source]

Possible values for the padding argument in PreTrainedTokenizerBase.__call__(). Useful for tab-completion in an IDE.

class transformers.file_utils.TensorType(value)[source]

Possible values for the return_tensors argument in PreTrainedTokenizerBase.__call__(). Useful for tab-completion in an IDE.

Special Decorators

transformers.file_utils.add_start_docstrings(*docstr)[source]
transformers.file_utils.add_start_docstrings_to_model_forward(*docstr)[source]
transformers.file_utils.add_end_docstrings(*docstr)[source]
transformers.file_utils.add_code_sample_docstrings(*docstr, processor_class=None, checkpoint=None, output_type=None, config_class=None, mask=None, model_cls=None, modality=None)[source]
transformers.file_utils.replace_return_docstrings(output_type=None, config_class=None)[source]

Special Properties

class transformers.file_utils.cached_property[source]

Descriptor that mimics @property but caches output in member variable.

From tensorflow_datasets

Built-in in functools from Python 3.8.

Other Utilities

class transformers.file_utils._LazyModule(name, module_file, import_structure, module_spec=None, extra_objects=None)[source]

Module class that surfaces all objects but only performs associated imports when the objects are requested.