---
local: general-utilities
sections:
- local: transformers.file_utils.ExplicitEnum
  title: Enums and namedtuples
- local: transformers.add_start_docstrings
  title: Special Decorators
- local: transformers.file_utils.cached_property
  title: Special Properties
- local: transformers._LazyModule
  title: Other Utilities
title: General Utilities
---
<script>
import Tip from "./Tip.svelte";
import Youtube from "./Youtube.svelte";
import Docstring from "./Docstring.svelte";
import CodeBlock from "./CodeBlock.svelte";
import CodeBlockFw from "./CodeBlockFw.svelte";
import DocNotebookDropdown from "./DocNotebookDropdown.svelte";
import IconCopyLink from "./IconCopyLink.svelte";
export let fw: "pt" | "tf"
</script>
<!--Copyright 2021 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

<h1 id="general-utilities">General Utilities</h1>

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.


<h2 id="transformers.file_utils.ExplicitEnum">Enums and namedtuples</h2>

<div class="docstring">

<docstring><name>class transformers.file\_utils.ExplicitEnum</name><anchor>transformers.file_utils.ExplicitEnum</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/file_utils.py#L2693</source><parameters>[{"name": "value", "val": ""}, {"name": "names", "val": " = None"}, {"name": "module", "val": " = None"}, {"name": "qualname", "val": " = None"}, {"name": "type", "val": " = None"}, {"name": "start", "val": " = 1"}]</parameters></docstring>

Enum with more explicit error message for missing values.


</div>

<div class="docstring">

<docstring><name>class transformers.file\_utils.PaddingStrategy</name><anchor>transformers.file_utils.PaddingStrategy</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/file_utils.py#L2705</source><parameters>[{"name": "value", "val": ""}, {"name": "names", "val": " = None"}, {"name": "module", "val": " = None"}, {"name": "qualname", "val": " = None"}, {"name": "type", "val": " = None"}, {"name": "start", "val": " = 1"}]</parameters></docstring>

Possible values for the `padding` argument in [PreTrainedTokenizerBase.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__). Useful for tab-completion in an
IDE.


</div>

<div class="docstring">

<docstring><name>class transformers.TensorType</name><anchor>transformers.TensorType</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/file_utils.py#L2716</source><parameters>[{"name": "value", "val": ""}, {"name": "names", "val": " = None"}, {"name": "module", "val": " = None"}, {"name": "qualname", "val": " = None"}, {"name": "type", "val": " = None"}, {"name": "start", "val": " = 1"}]</parameters></docstring>

Possible values for the `return_tensors` argument in [PreTrainedTokenizerBase.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__). Useful for
tab-completion in an IDE.


</div>

<h2 id="transformers.add_start_docstrings">Special Decorators</h2>

<div class="docstring">
</div>

<div class="docstring">
</div>

<div class="docstring">
</div>

<div class="docstring">
</div>

<div class="docstring">
</div>

<h2 id="transformers.file_utils.cached_property">Special Properties</h2>

<div class="docstring">

<docstring><name>class transformers.file\_utils.cached\_property</name><anchor>transformers.file_utils.cached_property</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/file_utils.py#L2449</source><parameters>[{"name": "fget", "val": " = None"}, {"name": "fset", "val": " = None"}, {"name": "fdel", "val": " = None"}, {"name": "doc", "val": " = None"}]</parameters></docstring>

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

From tensorflow_datasets

Built-in in functools from Python 3.8.


</div>

<h2 id="transformers._LazyModule">Other Utilities</h2>

<div class="docstring">

<docstring><name>class transformers.\_LazyModule</name><anchor>transformers._LazyModule</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/file_utils.py#L2728</source><parameters>[{"name": "name", "val": ""}, {"name": "module_file", "val": ""}, {"name": "import_structure", "val": ""}, {"name": "module_spec", "val": " = None"}, {"name": "extra_objects", "val": " = None"}]</parameters></docstring>

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


</div>
