code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py _a = 'src/diffusers' # Matches is_xxx_available() _a = re.compile(R'is\_([a-z_]*)_avai...
61
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils ...
243
0
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : str ): if n_term == "": return [] __UpperCamelCase =[] for temp in range(int(SCREAMING_SNAKE_CASE__ ) ): series.append(F'1/{temp + 1}' if series else '1' ) return series if __name__ == "__m...
62
"""simple docstring""" from __future__ import annotations class snake_case : def __init__( self , __UpperCAmelCase) ->Any: a_ = TypeError( "Matrices must be formed from a list of zero or more lists containing at " "least one and the same numb...
243
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : Dict = logging.get_logger(__name__) lowerCAmelCase_ : int = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacod...
63
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCam...
243
0
"""simple docstring""" from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCAmelCase__ (snake_case__ : str , snake_case__ : str ): """simple docstring""" _snake_case : Optional[Any] ...
64
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase = "The quick brown fox jumps over the lazy dog" , ) ->bool: """simple docstring""" a_ = set() # Replace all the whitespace in our sentence a_ = input_str.replace(" " , "" ) for alpha in input...
243
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'JukeboxVQV...
65
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not i...
243
0
"""simple docstring""" import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODE...
66
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMod...
243
0
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import dis...
67
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.dat...
243
0
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a_...
68
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCamelCase ( UpperCAmelCase ) ->List[Any]: """simple docstring""" def is_in_circle(UpperCAmelCase , UpperCAmelCase ) -> bool: a_...
243
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase = { '''configuration_upernet''': ['''UperNetConfig'''], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable()...
69
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class snake_case ...
243
0
'''simple docstring''' from collections import defaultdict from math import gcd def UpperCamelCase__ ( lowerCAmelCase = 1_50_00_00 ): """simple docstring""" _lowerCAmelCase = defaultdict(lowerCAmelCase ) _lowerCAmelCase ...
70
"""simple docstring""" import baseaa def UpperCamelCase ( UpperCAmelCase ) ->bytes: """simple docstring""" return baseaa.baaencode(string.encode("utf-8" ) ) def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return baseaa.baadecode(UpperCAmelCase ).dec...
243
0
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter A_ ...
71
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from tra...
243
0
"""simple docstring""" import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def snake_case_ ( A_ : Dict, A_ : str, A_ : str, A_ : Path, A_ : str = None, ...
72
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = {'configuration_xgl...
243
0
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> int: __lowerCamelCase : List[Any] = hex_num.strip() if not hex_num: raise ValueError('No value was passed to the function' ) __lowerCamelCase : List[Any] = hex_num[0] == '-' if is_negative: __lowe...
73
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class snake_case ( SCREAMING_SNAKE_CASE_ ): a_ : int = (KDPMaDiscreteScheduler,) a_ : List[str] =...
243
0
"""simple docstring""" import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from ...
74
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->int: """simple docstring""" a_ = [[0 for _ in range(UpperCAmelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): a_ = 1 for n in range(m + 1 ): for k in range(1 , UpperCAmelC...
243
0
'''simple docstring''' import math def a_ ( __snake_case : int ) -> bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
75
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class snake_case ( unittest.TestCase ): a_ : Any = JukeboxTokenizer a_ : Any = { """artist""": """Zac Brown Band""", ""...
243
0
def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : str = 0 # if input_string is "aba" than new_input_string become "a|b|a" SCREAMING_SNAKE_CASE : Any = "" SCREAMING_SNAKE_CASE : Any = "" # append each character + "|" in new_string for range(0, length...
76
"""simple docstring""" UpperCamelCase_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} UpperCamelCase_ = ['a', 'b', 'c', 'd', 'e'] def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) ->Optional[int]: """simple docstring""" ...
243
0
"""simple docstring""" from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available...
77
"""simple docstring""" import math import os import sys def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" a_ = "" try: with open(UpperCAmelCase , "rb" ) as binary_file: a_ = binary_file.read() for dat in data: a_ ...
243
0
"""simple docstring""" import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem ...
78
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->list[int]: """simple docstring""" if length <= 0 or not isinstance(UpperCAmelCase , UpperCAmelCase ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(UpperCAmelCa...
243
0
'''simple docstring''' import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational imp...
79
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snak...
243
0
'''simple docstring''' # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class lowercase_ ( a__ ): def __init__( self , a , a ): super().__init__() se...
80
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, ...
243
0
"""simple docstring""" def _A ( lowercase ): """simple docstring""" if not isinstance(lowercase , lowercase ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) a =0 while number: # This way we a...
81
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return " ".join( "".join(word[::-1] ) if len(UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() pr...
243
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from .test_pipelines...
82
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vi...
243
0
'''simple docstring''' import math import sys def A__ ( UpperCAmelCase_ ): _UpperCamelCase : Union[str, Any] = '' try: with open(UpperCAmelCase_ , 'rb' ) as binary_file: _UpperCamelCase : int = binary_file.read() ...
83
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils ...
243
0
"""simple docstring""" def _snake_case ( lowercase__ : dict ) -> set: '''simple docstring''' lowerCAmelCase_ :Any = set() # edges = list of graph's edges lowerCAmelCase_ :List[Any] = get_edges(lowercase__ ) # While there are st...
84
"""simple docstring""" from __future__ import annotations class snake_case : def __init__( self , __UpperCAmelCase) ->Any: a_ = TypeError( "Matrices must be formed from a list of zero or more lists containing at " "least one and the same numb...
243
0
'''simple docstring''' import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _snake_case ( lowercase_ ): def lowerCAmelCase__ ( self , a__ ) -> Dict: '''simple docstring''' with ...
85
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCam...
243
0
"""simple docstring""" import os from pathlib import Path def __lowerCAmelCase (): from torch.utils.cpp_extension import load __lowerCAmelCase : Dict = Path(_UpperCamelCase ).resolve().parent.parent.parent / 'kernels' / 'deformable_detr' __lowerCAmelCase : int = ...
86
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase = "The quick brown fox jumps over the lazy dog" , ) ->bool: """simple docstring""" a_ = set() # Replace all the whitespace in our sentence a_ = input_str.replace(" " , "" ) for alpha in input...
243
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': ['''MCTCTFeatureExtractor'''...
87
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not i...
243
0
def a__ ( A_, A_ ): '''simple docstring''' __magic_name__ = int(A_ ) # Initialize Result __magic_name__ = [] # Traverse through all denomination for denomination in reversed(A_ ): # Find denominations while int(...
88
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMod...
243
0
'''simple docstring''' import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp f...
89
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.dat...
243
0
__A = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "huggin...
90
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCamelCase ( UpperCAmelCase ) ->List[Any]: """simple docstring""" def is_in_circle(UpperCAmelCase , UpperCAmelCase ) -> bool: a_...
243
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ : Optional[int] = {"""configuration_vit""": ["""VIT_PR...
91
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class snake_case ...
243
0
def _a ( SCREAMING_SNAKE_CASE_ : int = 1_00 ): __lowerCAmelCase = (n * (n + 1) // 2) ** 2 __lowerCAmelCase = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(f'''{solution() = }''')
92
"""simple docstring""" import baseaa def UpperCamelCase ( UpperCAmelCase ) ->bytes: """simple docstring""" return baseaa.baaencode(string.encode("utf-8" ) ) def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return baseaa.baadecode(UpperCAmelCase ).dec...
243
0
'''simple docstring''' import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ...
93
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from tra...
243
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging snake_case : Dict = logging.get_logger(__name__) snake_case : Tuple ...
94
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = {'configuration_xgl...
243
0
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def _A ( SCREAMING_SNAKE_CASE : str = "laptop" ): """simple docstring""" a__ : Optional[int] =f'''https://www.amazon.in/laptop/s?k={pro...
95
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class snake_case ( SCREAMING_SNAKE_CASE_ ): a_ : int = (KDPMaDiscreteScheduler,) a_ : List[str] =...
243
0
"""simple docstring""" import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import ...
96
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->int: """simple docstring""" a_ = [[0 for _ in range(UpperCAmelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): a_ = 1 for n in range(m + 1 ): for k in range(1 , UpperCAmelC...
243
0
'''simple docstring''' def a ( __a , __a ) -> int: '''simple docstring''' if len(__a ) != len(__a ): raise ValueError('''String lengths must match!''' ) UpperCamelCase__ :Union[str, Any] = 0 for chara, chara in zip(__a , __a ): ...
97
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class snake_case ( unittest.TestCase ): a_ : Any = JukeboxTokenizer a_ : Any = { """artist""": """Zac Brown Band""", ""...
243
0
"""simple docstring""" def a_ ( lowerCamelCase ): if len(lowerCamelCase ) <= 1: return [tuple(lowerCamelCase )] UpperCAmelCase__ = [] def generate(lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = [0] *...
98
"""simple docstring""" UpperCamelCase_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} UpperCamelCase_ = ['a', 'b', 'c', 'd', 'e'] def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) ->Optional[int]: """simple docstring""" ...
243
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowercase : Any = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: if not is_to...
99
"""simple docstring""" import math import os import sys def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" a_ = "" try: with open(UpperCAmelCase , "rb" ) as binary_file: a_ = binary_file.read() for dat in data: a_ ...
243
0
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. 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....
100
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->list[int]: """simple docstring""" if length <= 0 or not isinstance(UpperCAmelCase , UpperCAmelCase ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(UpperCAmelCa...
243
0
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": lowercase__ :Any = pd.read_csv("sample_data.csv", header=None) lowercase__ :Optional[Any]...
101
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snak...
243
0
"""simple docstring""" import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, requ...
102
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, ...
243
0
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils import logging ...
103
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return " ".join( "".join(word[::-1] ) if len(UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() pr...
243
0
'''simple docstring''' def _A ( A__ , A__ ): """simple docstring""" __lowercase = len(A__ ) print('''The following activities are selected:''' ) # The first activity is always selected __lowercase = 0 print(A__ , end=''',''' ) # Consid...
104
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vi...
243
0
"""simple docstring""" from __future__ import annotations import math import random from typing import Any class __UpperCamelCase : def __init__( self ) -> None: a : list[Any] = [] a : int = 0 a : int ...
105
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils ...
243
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils im...
106
"""simple docstring""" from __future__ import annotations class snake_case : def __init__( self , __UpperCAmelCase) ->Any: a_ = TypeError( "Matrices must be formed from a list of zero or more lists containing at " "least one and the same numb...
243
0
class snake_case__ : """simple docstring""" def __init__( self : Optional[Any] , __lowerCamelCase : int ) -> List[str]: # we need a list not a string, so do something to change the type a = arr.split("," ) def _...
107
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCam...
243
0
"""simple docstring""" import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def a__ ( SCREAMING_SNAKE_CASE : Dataset , SCREAMING_SNAKE_CASE : Dict[st...
108
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase = "The quick brown fox jumps over the lazy dog" , ) ->bool: """simple docstring""" a_ = set() # Replace all the whitespace in our sentence a_ = input_str.replace(" " , "" ) for alpha in input...
243
0
"""simple docstring""" import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def _snake_case ( UpperCamelCase : Optional[Any] ...
109
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not i...
243
0
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class A ( unittest.TestCase ): __snake_case = JukeboxTokenizer __snake_case = { """artist""": """Zac Brown Band""", """genres""": """Country""", """lyri...
278
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMod...
243
0
def lowercase_ ( _lowerCamelCase : Union[str, Any]): lowercase__ : Optional[Any] = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
87
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.dat...
243
0
"""simple docstring""" import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(SCREAMING_SN...
315
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCamelCase ( UpperCAmelCase ) ->List[Any]: """simple docstring""" def is_in_circle(UpperCAmelCase , UpperCAmelCase ) -> bool: a_...
243
0
'''simple docstring''' def snake_case_ ( __SCREAMING_SNAKE_CASE : List[str] , __SCREAMING_SNAKE_CASE : Optional[Any] ): """simple docstring""" lowercase_ : Tuple = len(__SCREAMING_SNAKE_CASE ) print('''The...
93
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class snake_case ...
243
0
'''simple docstring''' from typing import TYPE_CHECKING from ..models.auto import AutoModelForVisionaSeq from ..utils import requires_backends from .base import PipelineTool if TYPE_CHECKING: from PIL import Image class __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE_ ): """simple ...
63
"""simple docstring""" import baseaa def UpperCamelCase ( UpperCAmelCase ) ->bytes: """simple docstring""" return baseaa.baaencode(string.encode("utf-8" ) ) def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return baseaa.baadecode(UpperCAmelCase ).dec...
243
0
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowercase ( _SCREAMING_SNAKE_CASE : Tuple , _SCREAMING_SNAKE_CASE : Dict=False ): '''simple docstri...
260
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from tra...
243
0
'''simple docstring''' import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertToken...
97
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = {'configuration_xgl...
243
0
import os import sys import transformers __A : List[Any] = '''3''' print('''Python version:''', sys.version) print('''transformers version:''', transformers.__version__) try: import torch print('''Torch version:''', torch.__version__) print('''Cuda available:''', torch.cuda.is_available()) p...
138
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class snake_case ( SCREAMING_SNAKE_CASE_ ): a_ : int = (KDPMaDiscreteScheduler,) a_ : List[str] =...
243
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : int = logging.get_logger(__name__) UpperCAmelCase : Optional[Any] = { 'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config....
115
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->int: """simple docstring""" a_ = [[0 for _ in range(UpperCAmelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): a_ = 1 for n in range(m + 1 ): for k in range(1 , UpperCAmelC...
243
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _UpperCAmelCase ( ...
264
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class snake_case ( unittest.TestCase ): a_ : Any = JukeboxTokenizer a_ : Any = { """artist""": """Zac Brown Band""", ""...
243
0
'''simple docstring''' import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def A__ ( UpperCAmel...
83
"""simple docstring""" UpperCamelCase_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} UpperCamelCase_ = ['a', 'b', 'c', 'd', 'e'] def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) ->Optional[int]: """simple docstring""" ...
243
0
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): im...
278
"""simple docstring""" import math import os import sys def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" a_ = "" try: with open(UpperCAmelCase , "rb" ) as binary_file: a_ = binary_file.read() for dat in data: a_ ...
243
0
def lowercase_ ( _lowerCamelCase : Optional[Any] = 200): lowercase__ : Union[str, Any] = [1, 2, 5, 10, 20, 50, 100, 200] lowercase__ : Tuple = [0] * (pence + 1) lowercase__ : str = 1 # base case: 1 way to make 0 pence for coin in coins: ...
87
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->list[int]: """simple docstring""" if length <= 0 or not isinstance(UpperCAmelCase , UpperCAmelCase ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(UpperCAmelCa...
243
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a = {'''configuration_encoder_decoder''': ['''EncoderDecoderConfig''']} try: if not is_torch_av...
315
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snak...
243
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase :...
93
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, ...
243
0
'''simple docstring''' from __future__ import annotations def _lowerCamelCase ( lowercase : Optional[Any] , lowercase : Optional[Any] ) -> tuple[int, int]: if b == 0: return (1, 0) ((_a) , (_a)) = extended_euclid(lowercase , ...
63
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return " ".join( "".join(word[::-1] ) if len(UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() pr...
243
0
"""simple docstring""" from __future__ import annotations def lowercase ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : Union[str, Any] ): '''simple docstring''' if partitions <= 0: raise ValueError('''partitions must ...
260
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vi...
243
0
'''simple docstring''' import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class lowercase ( ...
97
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils ...
243
0
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path __A : List[str] = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) __A : Optional[Any] = [ord(letter) for letter in string.ascii_lowerca...
138
"""simple docstring""" from __future__ import annotations class snake_case : def __init__( self , __UpperCAmelCase) ->Any: a_ = TypeError( "Matrices must be formed from a list of zero or more lists containing at " "least one and the same numb...
243
0
"""simple docstring""" from __future__ import annotations class lowerCamelCase__ : """simple docstring""" def __init__( self : Optional[Any] , UpperCamelCase : Tuple ): '''simple docstring''' __UpperCAmelCase : str ...
115
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCam...
243
0
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessi...
264
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase = "The quick brown fox jumps over the lazy dog" , ) ->bool: """simple docstring""" a_ = set() # Replace all the whitespace in our sentence a_ = input_str.replace(" " , "" ) for alpha in input...
243
0
'''simple docstring''' from string import ascii_lowercase, ascii_uppercase def A__ ( UpperCAmelCase_ ): if not sentence: return "" _UpperCamelCase : int = dict(zip(UpperCAmelCase_ , UpperCAmelCase_ ) ) return lower_to_upper.get(sentence[0]...
83
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not i...
243
0
from __future__ import annotations import os from collections.abc import Mapping _A = tuple[int, int] class A : def __init__( self, UpperCamelCase__, UpperCamelCase__ ): """simple docstring""" lowerCAmelCase_ = vertices lowerCAmelCase_ = { ...
278
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMod...
243
0
from scipy.stats import pearsonr import datasets UpperCamelCase = '''\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that ea...
87
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.dat...
243
0
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from u...
315
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCamelCase ( UpperCAmelCase ) ->List[Any]: """simple docstring""" def is_in_circle(UpperCAmelCase , UpperCAmelCase ) -> bool: a_...
243
0
'''simple docstring''' import re def snake_case_ ( __SCREAMING_SNAKE_CASE : Optional[int] ): """simple docstring""" return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''' , str_ )] def snake_case_ ( __SCREAMING_SNA...
93
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class snake_case ...
243
0
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversat...
63
"""simple docstring""" import baseaa def UpperCamelCase ( UpperCAmelCase ) ->bytes: """simple docstring""" return baseaa.baaencode(string.encode("utf-8" ) ) def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return baseaa.baadecode(UpperCAmelCase ).dec...
243
0
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : Any ): '''simple docstring''' if number < 0: raise ValueError('''number must not be negative''' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest...
260
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from tra...
243
0
'''simple docstring''' import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats...
97
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = {'configuration_xgl...
243
0
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase = 10, _UpperCAmelCase = 22 ) -> int: '''simple docstring''' lowerCAmelCase : List[str] = range(1, _UpperCAmelCase ) lowerCAmelCase : str = range(1, _UpperCAmelCase ) return sum( 1 for power in ...
138
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class snake_case ( SCREAMING_SNAKE_CASE_ ): a_ : int = (KDPMaDiscreteScheduler,) a_ : List[str] =...
243
0
"""simple docstring""" from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward ...
115
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->int: """simple docstring""" a_ = [[0 for _ in range(UpperCAmelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): a_ = 1 for n in range(m + 1 ): for k in range(1 , UpperCAmelC...
243
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : str = logging.get_logger(__name__) lowercase__ : Tuple = { '''caidas/swin2sr-classicalsr-x2-64''': ( '''https://huggingface.co/caidas/swin2sr-classicalsr-...
264
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class snake_case ( unittest.TestCase ): a_ : Any = JukeboxTokenizer a_ : Any = { """artist""": """Zac Brown Band""", ""...
243
0
'''simple docstring''' import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import j...
83
"""simple docstring""" UpperCamelCase_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} UpperCamelCase_ = ['a', 'b', 'c', 'd', 'e'] def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) ->Optional[int]: """simple docstring""" ...
243
0
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers.mo...
278
"""simple docstring""" import math import os import sys def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" a_ = "" try: with open(UpperCAmelCase , "rb" ) as binary_file: a_ = binary_file.read() for dat in data: a_ ...
243
0
import os import platform import sys UpperCamelCase = '''3''' print('''Python version:''', sys.version) print('''OS platform:''', platform.platform()) print('''OS architecture:''', platform.machine()) try: import torch print('''Torch version:''', torch.__version__) p...
87
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->list[int]: """simple docstring""" if length <= 0 or not isinstance(UpperCAmelCase , UpperCAmelCase ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(UpperCAmelCa...
243
0
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_ax...
315
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snak...
243
0
'''simple docstring''' import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_de...
93
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, ...
243
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor lowerCAmelCase_ : Any = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE_ ): """simple docstring""" ...
63
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return " ".join( "".join(word[::-1] ) if len(UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() pr...
243
0
"""simple docstring""" import os import jsonlines import numpy as np from tqdm import tqdm __A : Dict = 2048 __A : Optional[Any] = 4096 __A : Any = 42 __A : Optional[int] = os.environ.pop("PROCESS_TRAIN", "false") __A ...
260
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vi...
243
0
'''simple docstring''' def a ( __a ) -> list[int]: '''simple docstring''' if length <= 0 or not isinstance(__a , __a ): raise ValueError('''Length must be a positive integer.''' ) return [n * (2 * n - 1) for n in range(__a )] if __name__ == "__main__": pri...
97
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils ...
243
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin __A : str = '''\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers....
138
"""simple docstring""" from __future__ import annotations class snake_case : def __init__( self , __UpperCAmelCase) ->Any: a_ = TypeError( "Matrices must be formed from a list of zero or more lists containing at " "least one and the same numb...
243
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase : Optional[Any] = { 'facebook/vit-mae-base': 'https://huggingface.co/facebook/vit-mae-base/...
115
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCam...
243
0
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class _UpperCAmelCase ( datasets.BeamBasedBuilder): def _snake_case ( ...
264
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase = "The quick brown fox jumps over the lazy dog" , ) ->bool: """simple docstring""" a_ = set() # Replace all the whitespace in our sentence a_ = input_str.replace(" " , "" ) for alpha in input...
243
0
'''simple docstring''' import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_...
83
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not i...
243
0
import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from torch.utils.data import Data...
278
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMod...
243
0
from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecate( '''pipelines_utils''', '''0.22.0''', '''Importing `DiffusionPipeline` or `ImagePipelineOutput` from diffusers.pipeline_utils is deprecated. Please import from diffusers.pipelines.pipe...
87
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.dat...
243
0
"""simple docstring""" import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import d...
315
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCamelCase ( UpperCAmelCase ) ->List[Any]: """simple docstring""" def is_in_circle(UpperCAmelCase , UpperCAmelCase ) -> bool: a_...
243
0
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ...
93
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class snake_case ...
243
0
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE_ ): ...
63
"""simple docstring""" import baseaa def UpperCamelCase ( UpperCAmelCase ) ->bytes: """simple docstring""" return baseaa.baaencode(string.encode("utf-8" ) ) def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return baseaa.baadecode(UpperCAmelCase ).dec...
243
0
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONF...
260
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from tra...
243
0
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingf...
97
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = {'configuration_xgl...
243
0