id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
11,489
import json import os import re import unicodedata from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging The provided code snippet includes necessary dependencies for implementing the `replace_unicode_punct` function. Write a Python function `def re...
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/replace-unicode-punctuation.perl
11,490
import json import os import re import unicodedata from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging The provided code snippet includes necessary dependencies for implementing the `remove_non_printing_char` function. Write a Python function `def...
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/remove-non-printing-char.perl
11,491
import itertools import random import warnings from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import numpy as np import tensorflow as tf from ...activations_tf import get_tf_activation from ...modeling_tf_outputs import ( TFBaseModelOutput, TFMultipleChoiceModelOutput, TFQ...
Generate hidden states mask, and optionally an attention mask.
11,492
import collections.abc import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from ...activations import ACT2FN from ...modeling_utils import PreTrainedModel from ...pytorch_utils import find_pruneable_heads_and_indices, pr...
Partitions the given input into windows.
11,493
import collections.abc import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from ...activations import ACT2FN from ...modeling_utils import PreTrainedModel from ...pytorch_utils import find_pruneable_heads_and_indices, pr...
Merges windows to produce higher resolution features.
11,494
import collections.abc import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from ...activations import ACT2FN from ...modeling_utils import PreTrainedModel from ...pytorch_utils import find_pruneable_heads_and_indices, pr...
Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). Comment by Ross Wightman: This is the same as the DropConnect impl I created for EfficientNet, etc networks, however, the original name is misleading as 'Drop Connect' is a different form of dropout in a separate paper... See discu...
11,495
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutFeatureExtractor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFast, ) def get_conf...
null
11,496
import dataclasses import json import sys from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Dict, Iterable, NewType, Optional, Tuple, Union, get_type_hints import ...
null
11,497
from ..utils import DummyObject, requires_backends def top_k_top_p_filtering(*args, **kwargs): requires_backends(top_k_top_p_filtering, ["torch"])
null
11,498
from ..utils import DummyObject, requires_backends def load_tf_weights_in_albert(*args, **kwargs): requires_backends(load_tf_weights_in_albert, ["torch"])
null
11,499
from ..utils import DummyObject, requires_backends def load_tf_weights_in_bert(*args, **kwargs): requires_backends(load_tf_weights_in_bert, ["torch"])
null
11,500
from ..utils import DummyObject, requires_backends def load_tf_weights_in_bert_generation(*args, **kwargs): requires_backends(load_tf_weights_in_bert_generation, ["torch"])
null
11,501
from ..utils import DummyObject, requires_backends def load_tf_weights_in_big_bird(*args, **kwargs): requires_backends(load_tf_weights_in_big_bird, ["torch"])
null
11,502
from ..utils import DummyObject, requires_backends def load_tf_weights_in_canine(*args, **kwargs): requires_backends(load_tf_weights_in_canine, ["torch"])
null
11,503
from ..utils import DummyObject, requires_backends def load_tf_weights_in_convbert(*args, **kwargs): requires_backends(load_tf_weights_in_convbert, ["torch"])
null
11,504
from ..utils import DummyObject, requires_backends def load_tf_weights_in_electra(*args, **kwargs): requires_backends(load_tf_weights_in_electra, ["torch"])
null
11,505
from ..utils import DummyObject, requires_backends def load_tf_weights_in_funnel(*args, **kwargs): requires_backends(load_tf_weights_in_funnel, ["torch"])
null
11,506
from ..utils import DummyObject, requires_backends def load_tf_weights_in_gpt2(*args, **kwargs): requires_backends(load_tf_weights_in_gpt2, ["torch"])
null
11,507
from ..utils import DummyObject, requires_backends def load_tf_weights_in_gpt_neo(*args, **kwargs): requires_backends(load_tf_weights_in_gpt_neo, ["torch"])
null
11,508
from ..utils import DummyObject, requires_backends def load_tf_weights_in_imagegpt(*args, **kwargs): requires_backends(load_tf_weights_in_imagegpt, ["torch"])
null
11,509
from ..utils import DummyObject, requires_backends def load_tf_weights_in_mobilebert(*args, **kwargs): requires_backends(load_tf_weights_in_mobilebert, ["torch"])
null
11,510
from ..utils import DummyObject, requires_backends def load_tf_weights_in_openai_gpt(*args, **kwargs): requires_backends(load_tf_weights_in_openai_gpt, ["torch"])
null
11,511
from ..utils import DummyObject, requires_backends def load_tf_weights_in_qdqbert(*args, **kwargs): requires_backends(load_tf_weights_in_qdqbert, ["torch"])
null
11,512
from ..utils import DummyObject, requires_backends def load_tf_weights_in_realm(*args, **kwargs): requires_backends(load_tf_weights_in_realm, ["torch"])
null
11,513
from ..utils import DummyObject, requires_backends def load_tf_weights_in_rembert(*args, **kwargs): requires_backends(load_tf_weights_in_rembert, ["torch"])
null
11,514
from ..utils import DummyObject, requires_backends def load_tf_weights_in_roformer(*args, **kwargs): requires_backends(load_tf_weights_in_roformer, ["torch"])
null
11,515
from ..utils import DummyObject, requires_backends def load_tf_weights_in_t5(*args, **kwargs): requires_backends(load_tf_weights_in_t5, ["torch"])
null
11,516
from ..utils import DummyObject, requires_backends def load_tf_weights_in_transfo_xl(*args, **kwargs): requires_backends(load_tf_weights_in_transfo_xl, ["torch"])
null
11,517
from ..utils import DummyObject, requires_backends def load_tf_weights_in_xlnet(*args, **kwargs): requires_backends(load_tf_weights_in_xlnet, ["torch"])
null
11,518
from ..utils import DummyObject, requires_backends def get_constant_schedule(*args, **kwargs): requires_backends(get_constant_schedule, ["torch"])
null
11,519
from ..utils import DummyObject, requires_backends def get_constant_schedule_with_warmup(*args, **kwargs): requires_backends(get_constant_schedule_with_warmup, ["torch"])
null
11,520
from ..utils import DummyObject, requires_backends def get_cosine_schedule_with_warmup(*args, **kwargs): requires_backends(get_cosine_schedule_with_warmup, ["torch"])
null
11,521
from ..utils import DummyObject, requires_backends def get_cosine_with_hard_restarts_schedule_with_warmup(*args, **kwargs): requires_backends(get_cosine_with_hard_restarts_schedule_with_warmup, ["torch"])
null
11,522
from ..utils import DummyObject, requires_backends def get_linear_schedule_with_warmup(*args, **kwargs): requires_backends(get_linear_schedule_with_warmup, ["torch"])
null
11,523
from ..utils import DummyObject, requires_backends def get_polynomial_decay_schedule_with_warmup(*args, **kwargs): requires_backends(get_polynomial_decay_schedule_with_warmup, ["torch"])
null
11,524
from ..utils import DummyObject, requires_backends def get_scheduler(*args, **kwargs): requires_backends(get_scheduler, ["torch"])
null
11,525
from ..utils import DummyObject, requires_backends def apply_chunking_to_forward(*args, **kwargs): requires_backends(apply_chunking_to_forward, ["torch"])
null
11,526
from ..utils import DummyObject, requires_backends def prune_layer(*args, **kwargs): requires_backends(prune_layer, ["torch"])
null
11,527
from ..utils import DummyObject, requires_backends def torch_distributed_zero_first(*args, **kwargs): requires_backends(torch_distributed_zero_first, ["torch"])
null
11,528
from ..utils import DummyObject, requires_backends def rescale(*args, **kwargs): requires_backends(rescale, ["vision"])
null
11,529
from ..utils import DummyObject, requires_backends def resize(*args, **kwargs): requires_backends(resize, ["vision"])
null
11,530
from ..utils import DummyObject, requires_backends def to_pil_image(*args, **kwargs): requires_backends(to_pil_image, ["vision"])
null
11,531
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
null
11,532
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
Returns a list of tuples representing model binaries that are cached locally. Each tuple has shape `(model_url, etag, size_MB)`. Filenames in `cache_dir` are use to get the metadata for each model, only urls ending with *.bin* are added. Args: cache_dir (`Union[str, Path]`, *optional*): The cache directory to search fo...
11,533
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
Extracts the commit hash from a resolved filename toward a cache file.
11,534
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
Tries to locate a file in a local folder and repo, downloads and cache it if necessary. Args: path_or_repo (`str` or `os.PathLike`): This can be either: - a string, the *model id* of a model repo on huggingface.co. - a path to a *directory* potentially containing the file. filename (`str`): The name of the file to loca...
11,535
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
Downloads a given url in a temporary file. This function is not safe to use in multiple processes. Its only use is for deprecated behavior allowing to download config/models with a single url instead of using the Hub. Args: url (`str`): The url of the file to download. proxies (`Dict[str, str]`, *optional*): A dictiona...
11,536
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
Checks if a repo contains a given file wihtout downloading it. Works for remote repos and local folders. <Tip warning={false}> This function will raise an error if the repository `path_or_repo` is not valid or if `revision` does not exist for this repo, but will return False for regular connection errors. </Tip>
11,537
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
null
11,538
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
Sends telemetry that helps tracking the examples use. Args: example_name (`str`): The name of the example. *example_args (dataclasses or `argparse.ArgumentParser`): The arguments to the script. This function will only try to extract the model and dataset name from those. Nothing else is tracked. framework (`str`, *opti...
11,539
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
For a given model: - download and cache all the shards of a sharded checkpoint if `pretrained_model_name_or_path` is a model ID on the Hub - returns the list of paths to all the shards, as well as some metadata. For the description of each arg, see [`PreTrainedModel.from_pretrained`]. `index_filename` is the full path ...
11,540
import json import os import re import shutil import sys import tempfile import traceback import warnings from pathlib import Path from typing import Dict, List, Optional, Tuple, Union from urllib.parse import urlparse from uuid import uuid4 import huggingface_hub import requests from huggingface_hub import ( Commi...
null
11,541
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length The provided code snippet includes necessary dependencies for implementing the `format_time` function. Write a Python function `def fo...
Format `t` (in seconds) to (h):mm:ss
11,542
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def html_progress_bar(value, total, prefix, label, width=300): # docstyle-ignore return f""" <div> {prefix} <p...
null
11,543
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length The provided code snippet includes necessary dependencies for implementing the `text_to_html_table` function. Write a Python function ...
Put the texts in `items` in an HTML table.
11,544
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,545
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,546
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,547
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,548
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,549
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,550
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,551
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,552
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,553
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,554
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,555
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,556
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,557
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
Checks if `torch_xla` is installed and potentially if a TPU is in the environment
11,558
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,559
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,560
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,561
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,562
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,563
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,564
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,565
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,566
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,567
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,568
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,569
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,570
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,571
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,572
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,573
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,574
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,575
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,576
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,577
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,578
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,579
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,580
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,581
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,582
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,583
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,584
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,585
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,586
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,587
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null
11,588
import importlib.util import json import os import shutil import sys import warnings from collections import OrderedDict from functools import lru_cache, wraps from itertools import chain from types import ModuleType from typing import Any from packaging import version from transformers.utils.versions import importlib_...
null