code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def A_ ( _lowerCamelCase : str ): _lowerCAmelCase = analyze_text(__lowerCAmelCase ) _lowerCAmelCase = list(' ' + ascii_lowercase ...
309
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _A ( UpperCAme...
269
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Dict = logging.get_logger(__name__) __lowerCamelCase : int = {} class UpperCAmelCase ( lowercase_): """simple docstring""" lowerC...
700
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers....
271
0
"""simple docstring""" def snake_case ( A__ ,A__ ,A__ ,A__ ): UpperCAmelCase_ , UpperCAmelCase_ : List[Any] = len(A__ ), len(grid[0] ) if ( min(A__ ,A__ ) < 0 or row == row_length or col == col_length or (row, col) in visit ...
95
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProces...
392
0
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_enviro...
455
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_commo...
455
1
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class _UpperCAmelCase : def __init__( self , a__ , a__=sys.maxsize ): ...
569
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _i...
569
1
import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Acce...
705
import itertools import string from collections.abc import Generator, Iterable def a__ ( snake_case , snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : List[Any] = iter(snake_case ) while True: __SCREAMING_SNAKE_CASE : int = tuple(itertools.isl...
131
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ 'microsoft/unispeech-sat-base-100h-libri-ft': ( 'https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/r...
521
from __future__ import annotations def __UpperCamelCase ( lowerCAmelCase__ : Dict , lowerCAmelCase__ : List[Any] , lowerCAmelCase__ : Any , lowerCAmelCase__ : Dict ): # noqa: E741 while r - l > 1: __a : Tuple = (l + r) // 2 if v...
521
1
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class _UpperCAmelCase ( ...
421
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def a_ ( lowerCAmelCase_ : List[Any] ): __lowerCAmelCase = [ 'decoder.version', 'decoder.output_projection.weight', '_floa...
421
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase : str = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try...
372
'''simple docstring''' lowerCAmelCase : List[str] = 2_5_6 # Modulus to hash a string lowerCAmelCase : Tuple = 1_0_0_0_0_0_3 def _A ( A ,A ) -> bool: lowercase : List[Any] = len(A ) lowercase : List[Any] = len(A ) ...
372
1
"""simple docstring""" from string import ascii_lowercase, ascii_uppercase def lowercase ( _snake_case : Tuple ) ->Optional[int]: """simple docstring""" if not sentence: return "" __snake_case : List[str] = dict(zip(lowerCAmelCase_ , lowerCAmelCase_ ) ) return lowe...
703
"""simple docstring""" import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...
229
0
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class _lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def UpperCAmelCase ( self ) -> Optional[int]: """simp...
381
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ = { '''configuration_pix2struct''': [ '''PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Pix2StructConfig''', ...
381
1
"""simple docstring""" from __future__ import annotations import time import numpy as np a : Any = [8, 5, 9, 7] a : Optional[int] = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] a : Union[str, Any] = [ ...
422
"""simple docstring""" import math a : str = 10 a : List[Any] = 7 a : Tuple = BALLS_PER_COLOUR * NUM_COLOURS def snake_case__ ( _SCREAMING_SNAKE_CASE = 2_0 ) ->str: UpperCAmelCase__ = math.comb(_SCREAMING_SNAKE_CASE , _SCR...
422
1
from collections import defaultdict def a__ ( lowercase__ ): '''simple docstring''' UpperCAmelCase_ =1 UpperCAmelCase_ =True for v in tree[start]: if v not in visited: ret += dfs(lowercase__ ) if ret % 2 =...
54
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __lowercase : Any =( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", """JH 8S TH AH QH""", """TS KS 5S ...
54
1
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_visio...
691
'''simple docstring''' import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small...
691
1
def _UpperCAmelCase ( UpperCAmelCase : int ): """simple docstring""" if not isinstance(UpperCAmelCase , UpperCAmelCase ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be posit...
519
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder __UpperCamelCase : Optional[Any] = '__DUMMY_TRANSFORMERS_USER__' __UpperCamelCase : Optional[Any] = 'Dummy User' __UpperCa...
519
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_di...
718
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets A = datasets.logging.get_logger(__name__) A = '\\n@inproceedings{bleurt,\n title={BLEURT: Learning Robust Metrics for Text Generation},\n author={Thibault Sellam and Dipanjan Da...
97
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : List[str] = { 'configuration_trajectory_transformer': [ 'TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TrajectoryTransformerConfig', ...
15
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester fro...
73
0
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowerCAmelCase__ ( unittest.TestCase ): def lowercase_ ( self ): '''simple docstring''' A__ = [ "safety_checker/pytorch_model...
706
"""simple docstring""" import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("""Googling.....""") __UpperCAmelCase ="""https://www.google.com/search?q=""" + """ """.join(sys.argv[1:]) __UpperCAmelCase ...
261
0
import baseaa def A_ ( _lowerCAmelCase ) -> bytes: return baseaa.baaencode(string.encode("utf-8" ) ) def A_ ( _lowerCAmelCase ) -> str: return baseaa.baadecode(_lowerCAmelCase ).decode("utf-8" ) if __name__ == "__main__": __lowerCamelCase : int = """Hello ...
629
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Confi...
629
1
"""simple docstring""" import math def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase ) -> float: if initial_intensity < 0: raise ValueError("""The value of intensity cannot be negative""" ) # handling of negative values of initial intensity if ang...
507
"""simple docstring""" import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _A = """src/transformers""" # This is to ma...
507
1
'''simple docstring''' import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def _A ( A__ , A__ , A__ , A__=5 ): """simple docstring""" assert masked_input.count('''<mask>''' ) == 1 __lowercase = torch.tensor(tokenizer.encode(A__ ,...
41
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
84
0
from __future__ import annotations def A ( UpperCAmelCase , UpperCAmelCase ): _snake_case : list[list[int]] = [] _snake_case : list[int] = [] _snake_case : int = 0 _snake_case : Tuple ...
717
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor __lowerCAmelCase :str = logging.get_logger(__name__) class _a( __A ): def __init__( self , *__snake_case , **__snake_case ) ...
278
0
'''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 UpperCam...
379
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available(): from transformer...
419
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'edbeeching/decision-transformer-gym-hopper-medium': ( 'https://huggingface.co/edbeeching/decision-transformer-gym-hopper-mediu...
706
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def snake_case_ (__A : np.ndarray ) -> np.ndarray: return input_array.reshape((input_array.size, 1) ) def snake_case_ (...
218
0
# 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.0 # # Unless required by app...
612
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impo...
612
1
'''simple docstring''' def SCREAMING_SNAKE_CASE( UpperCamelCase ,UpperCamelCase = False ) -> bool: if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 1_0 not in (1, 3, 7, 9): # can quickly check last digit return False if n > 3_3_1_7_0_4_4_...
718
'''simple docstring''' from __future__ import annotations import requests lowerCAmelCase__ = set( "approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked c...
471
0
'''simple docstring''' import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils...
120
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def UpperCamelCase ( __magic_name__ : Union[str, Any] , __magic_name__ : Any , __magic_name__ : List[str] , __magic_name__...
15
0
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging __a = logging.get_logger(__name__) # pylint: disable=invalid-name class UpperCamelCase__( lowerCAmelCase__ ): "...
689
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def UpperCamelCase_ ( a_ ) ->Tuple: A =FileLock(str(tmpdir / "foo.lock" ) ) A =FileLock(str(tmpdir / "foo.lock" ) ) A =0.01 with locka.acquire(): with pytest.raises(a_ ): A =time.tim...
689
1
from __future__ import annotations def __UpperCamelCase ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : int ): __a : list[list[int]] = [] __a : list[int] = [] __a : List[str] = 0 __a : Any ...
521
from __future__ import annotations def _A ( SCREAMING_SNAKE_CASE__ : tuple[int, int] , SCREAMING_SNAKE_CASE__ : int ): UpperCamelCase , UpperCamelCase :List[Any] = position UpperCamelCase :Any = [ (y + 1, x + 2), (y - 1, x + 2)...
658
0
def lowerCamelCase_ ( A : Optional[Any] = 50 ): """simple docstring""" lowerCAmelCase_ = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(row_length - bl...
702
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_...
413
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A__ : Optional[Any] = { '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileNetV2Config''', ...
171
import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelera...
171
1
def lowerCamelCase_(lowerCamelCase_ ) -> Union[str, Any]: if divisor % 5 == 0 or divisor % 2 == 0: return 0 UpperCAmelCase = 1 UpperCAmelCase = 1 while repunit: UpperCAmelCase = (10 * repunit + 1) % divisor ...
719
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokenizer else: __lo...
457
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCAmelCase_ ( lowerCamelCase_ , unittest.Test...
105
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__v...
662
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available _UpperCamelCase : str = { 'configuration_audio_spectrogram_transformer': [ 'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHI...
713
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer _UpperCamelCase : int = logging...
134
0
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAINT...
271
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ......
100
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor lowercase__ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( __snake_case ): def __init__(self , *_lowerca...
716
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { "sayakpaul/vit-msn-base": "https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json", # See all ViT M...
63
0
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __UpperCAmelCase ( ...
530
"""simple docstring""" # Copyright 2023 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 # # Unl...
530
1
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN...
212
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProc...
212
1
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __SCREAMING_SNAKE_CASE ( lowerCAmelC...
315
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _a ( ) -> List[Any]: """simple docstring""" lowerCamelCase__ : Any = { '''repo_name''': ['''test_repo1''', '''test_re...
315
1
import numpy as np def a ( A__ : Optional[Any] , A__ : Tuple , A__ : Union[str, Any] = 1e-12 , A__ : Tuple = 100 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(_lowercase )[0] == np.shape(_lowercase...
704
def a ( A__ : Optional[int] ) -> Tuple: """simple docstring""" _lowercase =[0] * len(A__ ) _lowercase =[] _lowercase =[] _lowercase =0 for values in graph.values(): for i in values: indegree[...
380
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a ( unittest.Te...
347
def UpperCamelCase( __UpperCamelCase : str ,__UpperCamelCase : str ): lowerCAmelCase_ : Any = len(__UpperCamelCase ) lowerCAmelCase_ : Optional[int] = [] for i in range(len(__UpperCamelCase ) - pat_len + 1 ): lowerCAmelCase_ : s...
171
0
from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase_ = logging.get_logger(__name__) # TODO: upload to AWS lowercase_ = { "yjernite/retribert-base-uncased": ( "https://huggingface.co/yjernite/retribert-base-uncased/resolve/main/config.json"...
586
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase_ = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", "M2M100OnnxConfig"], "tokenization_m2m_100": ["M2M1...
586
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = {''...
565
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase = {'''configuration_opt''': ['''OPT_PRETRAINED_CONFIG_...
565
1
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import ...
718
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler...
324
0
"""simple docstring""" import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitesp...
49
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class __magic_name__ ( _UpperCamelCase ): @staticmethod @abstractmethod def __lowercase ( _UpperCAmelCase : ArgumentParser ): raise NotImplementedEr...
358
0
'''simple docstring''' import cmath import math def UpperCamelCase_ ( A__ : float , A__ : float , A__ : float , A__ : float ): '''simple docstring''' lowerCAmelCase_ : List[str] ...
398
'''simple docstring''' def UpperCamelCase_ ( A__ : int ): '''simple docstring''' assert isinstance(A__ , A__ ), f'The input value of [n={number}] is not an integer' if number == 1: return 2 elif number < 1: lowerCAmelCase_ ...
398
1
def UpperCAmelCase_ ( ) -> int: return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(__lowerCAmelCase , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == "__main__": print(F'{soluti...
509
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokenizat...
509
1
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def _snake_case ( snake_case__ : int ): if not isinstance(snake_case__ , snake_case__ ): raise TypeError('Undefined for non-integers' ) elif precision < 1: raise ValueError('U...
22
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats...
22
1
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = len(lowercase__ ) __lowercase = len(lowercase__ ) __lowercase = ( first_str_length if first_str_length > second_str_length else second_str_length ) ...
80
def __UpperCamelCase ( lowercase__ : int , lowercase__ : int ) -> int: '''simple docstring''' while b: lowerCAmelCase_ , lowerCAmelCase_ : int = b, a % b return a def __UpperCamelCase ( lowercase__ : ...
600
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class lowercase ( unittest.TestCase ): ...
719
def snake_case (UpperCamelCase : int ): '''simple docstring''' lowerCamelCase__ = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(2_7)) print(perfect_cube(4))
235
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) UpperCamelCase__ : Union[str, Any] = { """configuration_trocr""": ["""TROCR_PRE...
387
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase__ : Optional[Any] = { """configuration_bloom""": ["""BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BloomConfig""", """Bloo...
387
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Any = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ ="""encoder-decoder""" SCREAMING_SNAKE_CASE__ ...
720
# 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.0 # # Unless requ...
214
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { '''facebook/xlm-roberta-xl''': '''https://huggi...
14
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging A: Optional[int] = logging.get_logger(__name__) A: Dict = { "microsoft/unispeech-sat-base-100h-libri-ft": ( "https://huggingface.co/m...
160
0
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class lowerCamelCase__ ( yaml.SafeLoader): """simple docstring""" def _a (self , __a ): '''simple docstring''' ...
484
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 lowerCamelCase__ ( unittest...
484
1
"""simple docstring""" import math class __lowercase : '''simple docstring''' def _lowerCamelCase ( self , _UpperCAmelCase , _UpperCAmelCase ): __a : List[str] = 0.0 __a : ...
52
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 __lowercase = logging.get_logger(__name__) __lowercase = {'''vocab_file''': '''sen...
167
0
'''simple docstring''' def __snake_case( _lowerCAmelCase , _lowerCAmelCase ) -> float: if digit_amount > 0: return round(number - int(_lowerCAmelCase ) , _lowerCAmelCase ) return number - int(_lowerCAmelCase ) if __name__ == "__main__": print(decimal_isolat...
700
'''simple docstring''' def __snake_case( _lowerCAmelCase , _lowerCAmelCase ) -> tuple[float, float]: # Check if the input is valid if not len(_lowerCAmelCase ) == len(_lowerCAmelCase ) == 3: raise ValueError("""Please enter a valid equation.""" ) if equationa[0] =...
301
0
'''simple docstring''' import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImagePro...
116
lowerCAmelCase_ = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 1_0: "a", 1_1: "b", 1_2: "c", 1_3: "d", 1_4: "e", 1_5: "f", } def A_ ( lowercase_ ) -> str: assert type(lowercase_ ) in...
326
0
'''simple docstring''' from math import pow, sqrt def SCREAMING_SNAKE_CASE ( *a_ : float ): __a = len(_lowerCamelCase ) > 0 and all(value > 0.0 for value in values ) return result def SCREAMING_SNAKE_CASE ( a_ : float , a_ :...
706
'''simple docstring''' import torch from diffusers import StableDiffusionPipeline UpperCAmelCase_ = "path-to-your-trained-model" UpperCAmelCase_ = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("cuda") UpperCAmelCase_ = "A photo of sks dog...
490
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE :Dict = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Dict = { """naver-clova-ix/donut-base""": """https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json"""...
628
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ = 1_0_0_0_0_0_0 )-> int: """simple docstring""" UpperCamelCase_ = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , ...
628
1
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 ...u...
45
from __future__ import annotations import math from collections.abc import Callable def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 100 , ) -> float: lowercase__ = x_start lowercase__ ...
45
1
'''simple docstring''' import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import requir...
75
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE: Any = { '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''], } try: if not is_torch_a...
360
0
'''simple docstring''' import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class __SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self , _UpperCAmelCase=2 , _UpperCAmelCase=3 , _UpperCAmelCa...
709
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __magic_name__ = logging.get_logger(__name__) __magic_name__ ...
679
0
from __future__ import annotations def a__ ( snake_case , snake_case , snake_case , snake_case ): # noqa: E741 """simple docstring""" while r - l > 1: __SCREAMING_SNAKE_CASE : Optional[int] = (l + r) // 2 if v[m] >= key: __SCREAMING_SNA...
74
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable __snake_case = { """configuration_gpt_neox_japanese""": ["""GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoXJapaneseConfig"...
451
0
from __future__ import annotations def UpperCAmelCase ( lowerCAmelCase__ ): '''simple docstring''' if not nums: return 0 __A = nums[0] __A = 0 for num in nums[1:]: __A , __A = ( max_excluding + num, ...
205
from __future__ import annotations from typing import Any def UpperCAmelCase ( lowerCAmelCase__ ): '''simple docstring''' create_state_space_tree(lowerCAmelCase__ , [] , 0 ) def UpperCAmelCase ( lowerCAmelCase__ , lowerCAmelCase__ , lowerC...
205
1
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNetYaagf, RegNetYa...
431
def __UpperCamelCase ( _A ): if not isinstance(_A , _A ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) lowerCAmelCase_ = 0 while number: # This way we arrive at next set bit (next 1) instead of looping ...
431
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase__ : Optional[Any] = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_...
713
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def A_( A , A , **A ): UpperCAmelCase_ = AutoConfig.from_pretrained(A , **A ) UpperCAmelCase_ = AutoModelForSeqaSeqLM.from_config(A ) model.save_pr...
486
0
'''simple docstring''' import requests A = '''''' # <-- Put your OpenWeatherMap appid here! A = '''https://api.openweathermap.org/data/2.5/''' def SCREAMING_SNAKE_CASE ( lowerCAmelCase__ : str = "Chicago" , lowerCAmelCase__ : str = APPID) -> Tupl...
125
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDepen...
580
0
from maths.prime_check import is_prime def _UpperCAmelCase (UpperCamelCase_ : int ): '''simple docstring''' if not isinstance(UpperCamelCase_ , UpperCamelCase_ ): _lowerCAmelCase : Dict = F"Input value of [number={number}] must be an integer" ...
196
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.preprocessing import PolynomialFea...
196
1
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version lowerCAmelCase_ = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize lowerCAmelCase_ = "\\n@in...
326
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def A_ ( ) -> int: _snake_case : Optional[int] = { '''repo_name''': ['''test_repo1''', '''test_repo2''', '''test_repo3''']...
326
1
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class _a : '''simple docstring''' UpperCamelCa...
713
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, tra...
120
0
# 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 r...
663
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobert...
663
1
'''simple docstring''' def a_ ( __UpperCAmelCase , __UpperCAmelCase ) -> bool: """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
347
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class a_ ( snake_cas...
347
1
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _snake_case : List[str] = logging.get_logger(__name__) def lowerCAmelCase_ ( __lowerCamelCase ): if isinstance(__lowerCamelCase , np.ndarray )...
81
'''simple docstring''' import requests from bsa import BeautifulSoup def lowercase__ ( __UpperCamelCase = "AAPL" )-> str: UpperCamelCase = F"https://in.finance.yahoo.com/quote/{symbol}?s={symbol}" UpperCamelCase = BeautifulSoup(...
301
0
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import req...
704
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelT...
601
0
'''simple docstring''' import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class ...
24
def _lowerCAmelCase ( _lowerCAmelCase ) -> int: '''simple docstring''' assert column_title.isupper() __snake_case = 0 __snake_case = len(_lowerCAmelCase ) - 1 __snake_case = 0 while index >= 0: __snake...
371
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from...
109
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffuser...
109
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase = { 'configuration_whisper': ['WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP'...
114
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __A ( lowerCamelCase__ )...
114
1
'''simple docstring''' import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets lowercase__ = "\\n@inproceedings{snover-etal-2006-study,\n title = \"A Study of Translation Edit Rate with Targeted Human Annotation\",\n author = \"Snover, Matthew and\n Do...
276
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { "YituTech/conv-bert-base": "https...
276
1
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accelerat...
611
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase_ = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltCLIPTextConfig", ...
611
1
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock im...
718
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list ...
558
0
'''simple docstring''' import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging UpperCam...
28
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def lowerCAmelCase_ ( ): """simple docstring""" wit...
616
0
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPooli...
236
import heapq def a__ ( a ) -> set[int]: A_ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min priority queue, s...
236
1
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import ca...
468
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling_tf_au...
468
1
'''simple docstring''' import fcntl import os import socket import torch import torch.distributed as dist def SCREAMING_SNAKE_CASE ( *lowercase_ : Any ): with open(UpperCamelCase__ , """r""" ) as fh: fcntl.flock(UpperCamelCase__ , fcntl.LOCK_EX ) ...
720
'''simple docstring''' import os def SCREAMING_SNAKE_CASE ( ): lowercase = os.path.join(os.path.dirname(lowercase_ ) , """num.txt""" ) with open(lowercase_ ) as file_hand: return str(sum(int(lowercase_ ) for line in file_hand ) ...
653
0
"""simple docstring""" from typing import Any class lowercase_ : def __init__( self : Optional[Any] , _lowercase : Any ): lowerCAmelCase__ : Tuple = data lowerCAmelCase__ : List[str] = None ...
308
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_pro...
308
1
import re def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: str ) -> str: if len(re.findall("[ATCG]" , lowerCAmelCase ) ) != len(lowerCAmelCase ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) if __name__ == "__main__": ...
708
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: str , lowerCAmelCase: str ) -> int: if len(lowerCAmelCase ) != len(lowerCAmelCase ): raise ValueError("String lengths must match!" ) _UpperCAmelCase : List[Any] = 0 for chara, chara in zip(lowerCAmelCase , ...
467
0
'''simple docstring''' import numpy as np import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel from ...utils import logging __lowerCamelCase : str = logging.get_logger(__name__) class lowerCAmelCase__ ( __lowercase )...
501
from math import isqrt def __UpperCamelCase (lowerCAmelCase : int ) -> bool: return all(number % divisor != 0 for divisor in range(2, isqrt(lowerCAmelCase ) + 1 ) ) def __UpperCamelCase (lowerCAmelCase : int = 10**6 ) -> int: A = 0 A = 1 ...
699
0
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ...
144
import argparse import collections import json import os import re import string import sys import numpy as np UpperCamelCase = re.compile(r'''\b(a|an|the)\b''', re.UNICODE) UpperCamelCase = None def _a ( ) -> Tuple: lowerCamelCase_ : Optional[int] = ar...
144
1
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, se...
333
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase =logging.get_logger(__name__) __lowerCAmelCase ={ "huggingface/informer-tourism-monthly": ( "https://huggingface.co/huggingface/informer-tourism-mon...
333
1
"""simple docstring""" # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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/licen...
24
"""simple docstring""" from itertools import permutations def UpperCAmelCase ( A : tuple ): '''simple docstring''' if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False ...
24
1
"""simple docstring""" import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.s...
617
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__ : List[str] = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''...
286
0
import os def lowercase_ ( ): """simple docstring""" with open(os.path.dirname(_A ) + "/p022_names.txt" ) as file: lowerCamelCase__ : List[Any] = str(file.readlines()[0] ) lowerCamelCase__ : List[Any] = names.replace("\"" ...
5
from __future__ import annotations def lowercase_ ( _A : str , _A : list[str] | None = None , _A : dict[str, float] | None = None , _A : bool = False , ): """simple docstring""" lowerCamelCase__ : Tuple = ...
5
1
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _lowerCAmelCase ( __snake_case : List[str] ) -> Any: if ( (cp >= 0x4_e_0_0 and cp <= 0x9_f_f_f) ...
8
"""simple docstring""" import random from typing import Any def lowercase__ ( lowercase_ ) -> list[Any]: """simple docstring""" for _ in range(len(lowercase_ ) ): _UpperCamelCase : Dict = random.randint(0 ,len(lowercase_ ...
624
0
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowerCamelCase (__lowerCamelCase ): """simple docstring""" UpperCAmelCase_ = ["image_proces...
715
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=13_37 , num_examples=42 , dataset_n...
157
0
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def lowercase_ (A : Union[str, Any] , A : Optional[int] , A : str ): snake_case__ : Union[str, Any] = { 'en': 'Machine learning is great, isn\'t it?', ...
478
def lowercase_ (A : int , A : int ): if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) snake_case__ : List[str] = str(bin(A ) )[2:] # remove the leading "0b" snake_case__ : int = ...
478
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} try: if not is_torch_available(...
548
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, t...
548
1
import math def __snake_case ( __magic_name__ ): '''simple docstring''' return math.sqrt(__magic_name__ ) * math.sqrt(__magic_name__ ) == num def __snake_case ( __magic_name__ ): '''simple docstring''' lowercase = ...
441
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __snake_case ( ): '''simple docstring''' lowercase = ArgumentParser( description=( ...
441
1
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import B...
719
from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCamelCase__ : Any = logging.get_logger(__name__) lowerCamelCase__ : Union[str, Any] = { """CarlCochet/trajectory-transformer-halfcheetah-medium-v2""": ( """https...
208
0
'''simple docstring''' from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class __lowercase ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' a : List[str] = CustomTokenizer pass ...
502
"""simple docstring""" def _A ( __lowercase = 200_0000 ): """simple docstring""" lowerCamelCase__ = [0 for i in range(n + 1 )] lowerCamelCase__ = 1 lowerCamelCase__ = 1 for i in range(2 , int(n**0.5 ) ...
129
0
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/config....
16
"""simple docstring""" import baseaa def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' return baseaa.aaaencode(string.encode('utf-8' ) ) def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' return baseaa.aaadecod...
16
1