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
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _A : Optional[int] = get_tests...
100
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : Tuple ,lowerCAmelCase_ : Optional[int] ,lowerCAmelCase_ : Union[str, Any] ,lowerCAmelCase_ : Optional[Any]=1024 ...
220
0
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ = logging.get_logger(__name__) def UpperCamelCase__ ( a__ ): '''simple docstring'...
713
'''simple docstring''' 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 lowercase_ = logging.get_logger(__name__) lowerca...
58
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils import M...
333
import os def __UpperCamelCase ( ): """simple docstring""" with open(os.path.dirname(_lowerCAmelCase ) + "/grid.txt" ) as f: UpperCAmelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(_lowerCAmelCase ) for x in f.readline().split()] ) ...
333
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer __A ={'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} __A ={ 'voc...
703
'''simple docstring''' import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging __A =logging.get_logger(__name__) def _UpperCamelCase ( UpperCamelCase__ ): UpperCAme...
113
0
from collections import deque from math import floor from random import random from time import time class _lowerCamelCase : """simple docstring""" def __init__( self ) -> Optional[int]: """simple docstring""" UpperCamelCase__ : Optional[int] ...
285
import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_params import UNCONDITIONA...
285
1
import random def UpperCamelCase ( __lowercase : int ): '''simple docstring''' A_ : Tuple = num - 1 A_ : Optional[Any] = 0 while s % 2 == 0: A_ : Optional[int] = s // 2 t += 1 for _ in range(5 ): A_ ...
70
import numpy as np _UpperCAmelCase = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ] ...
70
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "microsoft/swinv2-tiny-patch4-window8-256": ( "https://huggingface.co/microsoft/swinv2-tiny-...
18
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSc...
688
0
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CO...
380
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger lowercase_ = '<<<<<<< This should probably be modified because it mentions: ' lowercase_ = ...
380
1
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import AN...
530
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCamelCase_ ( __lowerCAmelCase ) -> List[Any]: '''simple docstring''' def is_in_circle(__lowerCAmelCase , __lowerCAm...
530
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowerCamelCase : Dict = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''UniSpeechCon...
516
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ...
516
1
"""simple docstring""" from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone im...
357
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def A_ ( __lowercase , __lowercase , __lowercase = 1 , __lowercase = 1 , __lowercase = 1.0e4 , __lowercase = False , __lowercase = 1.0 , ): assert timesteps.ndim == 1, "Timesteps ...
357
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: ...
183
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { '''voc...
183
1
'''simple docstring''' UpperCAmelCase_ : Optional[int] = { '''Pillow''': '''Pillow<10.0.0''', '''accelerate''': '''accelerate>=0.20.3''', '''av''': '''av==9.2.0''', '''beautifulsoup4''': '''beautifulsoup4''', '''black''': '''black~=23.1''', '''codecarbon''': '''codecarbon==1....
24
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase : int = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'JukeboxV...
587
0
from __future__ import annotations import math def A__ ( lowerCamelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not pr...
670
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ : str = { """configuration_roformer""": ["""ROFORMER_PRETRAINED_CONFIG_ARC...
670
1
import math from collections.abc import Iterator from itertools import takewhile def __UpperCAmelCase ( a_): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even n...
198
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=snake_case_ ) class UpperCamelCase_ ( snake_case_ ): '''simple docstring''' lowerCAmelCase = field(default...
198
1
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor lowerCAmelCase__ = logging.get_logger(__name__) class a__ ( lowercase__ ): """simple docstring""" def __init__( self , *lowercase , **lowercase ) -> ...
700
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import PriorTransformer fr...
626
0
from __future__ import annotations def __lowerCAmelCase ( UpperCamelCase , UpperCamelCase = None , UpperCamelCase = None , UpperCamelCase = False , ) -> tuple[int, float, str]: lowerCAmelCase__ : Union[str, Any] = cipher_alphabet or [chr(A__ ) for ...
678
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowercase : Optional[Any] = {'configuration_reformer': ['REFOR...
649
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import Decoder, DecoderOutput, Encode...
664
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
664
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case_ ( UpperCAmelCase_ ): '''simple docstring''' __UpperCamelCase = ['''image_processor''', '''tokenizer'''] __UpperCamelCase = '''CLIPImageProcessor'''...
375
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ : Dict = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ : Union[str, Any] = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.jso...
375
1
'''simple docstring''' 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 ...
466
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_commo...
466
1
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputW...
193
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor UpperCamelCase_ : List[str] = logging.get_logger(__name__) class __lowercase ( __snake_case ): def __init__(self : int , *snake_case : Optional[Any] ...
461
0
"""simple docstring""" from __future__ import annotations from math import pow, sqrt def lowercase (_lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError("""One and only one argument must b...
703
"""simple docstring""" import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.war...
573
0
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require...
92
def _UpperCAmelCase ( A ): '''simple docstring''' for i in range(len(A ) - 1 , 0 , -1 ): UpperCAmelCase__ =False for j in range(A , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: UpperCAme...
625
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _UpperCAmelCase : Optional[int] = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = { "s...
700
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _UpperCAmelCase : Tup...
288
0
'''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_p...
459
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowercase = 4 lowercase = 3 class UpperCamelCase_ ( snake_case_ ): '''sim...
198
0
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMix...
291
# 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 # # U...
291
1
def a__ ( A_ ): '''simple docstring''' return 10 - x * x def a__ ( A_, A_ ): '''simple docstring''' if equation(SCREAMING_SNAKE_CASE__ ) * equation(SCREAMING_SNAKE_CASE__ ) >= 0: raise ValueError("""Wrong space!""" ) __magi...
529
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase_ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAva...
603
0
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowercase__ : UpperCamelCase_ = 42 # [batch_size x 3] UpperCamelCase_ = 42 # [batch_size x 3] UpperCamelCase_ = 42 # [batch_size x 3] UpperCamelCase_ = 4...
34
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def A ( _lowercase ): SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Union[str, Any] = analyze_text(_lowercase ) SCREAMING_SNAKE_CASE ...
34
1
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef __a: Union[str, Any] = ( "This metric will be removed from the library...
152
import os from datetime import datetime as dt from github import Github __lowerCamelCase : Optional[int] = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] def lowerCamelCase_() -> L...
323
0
import os import unicodedata 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 SPIECE_UNDERLINE, logging __lowerCAmelCase = logging.get_logger(_...
129
import re from filelock import FileLock try: import nltk __lowerCAmelCase = True except (ImportError, ModuleNotFoundError): __lowerCAmelCase = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) def __lowerCam...
129
1
"""simple docstring""" from __future__ import annotations lowerCAmelCase__ = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] lowerCAmelCase__ = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def snake_case_ ( A_ : list[float] )...
83
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor ...
156
0
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): if not all(char in '''01''' for char in bin_string ): raise ValueError('''Non-binary value was passed to the function''' ) if not bin_string: raise ValueError('''Empty string was passed to the function...
523
"""simple docstring""" import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class UpperCAmelCase_ ( unittest.TestCase ): def _lowerCamelCase ( self ) -> List[str]: ...
523
1
'''simple docstring''' import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import Aut...
614
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase__ : List[str] = logging.get_logger(__name__) UpperCamelCase__ : str = { ...
614
1
'''simple docstring''' def _lowerCamelCase ( lowercase : int , lowercase : int ) -> int: while a != 0: _a , _a = b % a, a return b def _lowerCamelCase ( lowercase : int , lowercase : int ) -> int: ...
700
'''simple docstring''' lowerCAmelCase_ : Optional[Any] = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def _lowerCamelCase ( lowercase : Union[str, Any] , ...
521
0
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_t...
56
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging UpperCAmelCase_ ...
255
0
"""simple docstring""" from __future__ import annotations from math import gcd def __A ( a_ : int , a_ : int = 2 , a_ : int = 1 , a_ : int = 3 , )-> int | None: '''simple docstring''' if num < 2: raise ValueError('''The input value cannot be le...
18
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __A ( a_ : float , a_ : float , a_ : bool = False )-> list[float]: '''simple docstring''' if radian_...
18
1
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def __SCREAMING_SNAKE_...
620
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding from ...utils import Te...
613
0
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_token...
720
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class a__ ( nn.Module ): """simple docstring""" UpperCAmelCase__ :...
446
0
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A_ ( A__ ): ...
174
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging lowerCAmelCa...
174
1
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def _lowercase ( UpperCamelCase_ ) -> str: '''s...
400
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , ) -> list[float]: '''simple docstring''' SCREAMING_SNAKE_CASE__ , ...
400
1
def __snake_case ( lowerCAmelCase_ ) -> float: SCREAMING_SNAKE_CASE__ = 0 while len(lowerCAmelCase_ ) > 1: SCREAMING_SNAKE_CASE__ = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): SCREAMING_SNAKE_...
100
'''simple docstring''' import unittest import numpy as np 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 ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avai...
195
0
import random def lowercase_ (A : List[str] , A : Tuple , A : int ): snake_case__ : List[str] = a[left_index] snake_case__ : Optional[int] = left_index + 1 for j in range(left_index + 1 , A ): if a[j] < ...
716
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # since ...
243
0
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { """facebook/encodec_24khz""": """https://huggingface.co/fa...
19
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(""".""") def lowerCAmelCase( __lowerCamelCase ): __a = test_file.split(os.path.sep ) if components[0:2] != ["te...
559
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_in...
700
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch ...
484
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ : Dict = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): ...
51
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging ...
39
0
'''simple docstring''' from math import factorial def __a ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k ...
340
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImag...
340
1
"""simple docstring""" def _A (__a ) -> str: """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
512
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrateg...
512
1
import argparse import json from tqdm import tqdm def _lowerCAmelCase ( ): '''simple docstring''' UpperCAmelCase = argparse.ArgumentParser() # Required parameters parser.add_argument( '''--src_path''' , type=A__ , default='''biencode...
391
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( A__: Optional[int] , A__: List[Any] , A__: str ): '''simp...
391
1
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class lowerCamelCase_( unittest.TestCase, A__ ): '''simple docstring''' def snake_case__ ( self ): _lowerCamelCase = load_tool('''tex...
661
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin ...
661
1
"""simple docstring""" 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...
295
"""simple docstring""" from collections.abc import Iterable from typing import Any class UpperCamelCase : def __init__( self , snake_case__ = None ): """simple docstring""" _SCREAMING_SNAKE_CASE : List[str] = value _SCREAMING_SNAKE_CASE ...
295
1
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __magic_name__ ( unittest.TestCase ): def lowerCAmelCase...
446
'''simple docstring''' from __future__ import annotations import time import numpy as np lowercase =[8, 5, 9, 7] lowercase =[ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] lowercase =[ [3, 2, 1, 4], [0, 2, 5, 2], [5, 1, 0, 5], [1, 5, 3, ...
446
1
from abc import ABC, abstractmethod from typing import List, Optional class snake_case_ (lowercase__ ): """simple docstring""" def __init__( self): """simple docstring""" self.test() def A_ ( self): """simple docstring""...
455
import logging from transformers import PretrainedConfig __lowerCamelCase = logging.getLogger(__name__) __lowerCamelCase = { '''bertabs-finetuned-cnndm''': '''https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json''', } class ...
455
1
"""simple docstring""" def __magic_name__ ( UpperCamelCase : list[int] ) -> list[int]: a__ = len(UpperCamelCase ) for i in range(UpperCamelCase ): for j in range(i + 1 , UpperCamelCase ): if numbers[j] < numbers[i]: a__ , ...
273
"""simple docstring""" 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 F...
273
1
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __lowerCAmelCase : Dict = (720, 1_280) # Height, Width __lowerCAmelCase : int = (0.4, 0.6) # if height or width lower than this scale, drop it. __lowe...
702
from math import factorial __lowerCAmelCase : Dict = {str(d): factorial(d) for d in range(10)} def UpperCAmelCase_ ( __lowerCAmelCase ) -> int: return sum(DIGIT_FACTORIAL[d] for d in str(__lowerCAmelCase ) ) def UpperCAmelCase_ ( ) -> int: __lowercas...
284
0
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class A_ : '''simple docstring''' @property def SCREAMING_SNAKE_CASE__ ( sel...
84
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCAmelCase = { '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTNeoOnnxConfig'''], } try: if not is_torch_a...
84
1
'''simple docstring''' from heapq import heappop, heappush import numpy as np def _lowercase ( UpperCamelCase__ : np.ndarray, UpperCamelCase__ : tuple[int, int], UpperCamelCase__ : tuple[int, int], UpperCamelCase__ : bool, ): __A : Optional[Any] ...
718
'''simple docstring''' from collections.abc import Sequence def _lowercase ( UpperCamelCase__ : Sequence[float], UpperCamelCase__ : float ): return sum(c * (x**i) for i, c in enumerate(UpperCamelCase__ ) ) def _lowercase ( UpperCamelCase__ : Sequenc...
540
0
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any =logging.get_logger(__name__) lowerCAmelCase__ : Union[str, Any] ={...
101
'''simple docstring''' import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging a : Optional[int] = logging.get_logger(__name__) def lowercase ( __magic_name__ ): '''simple docstring'...
679
0
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph class ...
721
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_availabl...
315
0
'''simple docstring''' import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCAmelCase ( UpperCAmelCase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE_ = (KDPMaDiscret...
42
"""simple docstring""" import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resol...
512
0
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): # noqa: E741 while r - l > 1: lowerCAmelCase_ : int =(l + ...
305
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowercase = { '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileNetV2Config...
305
1
"""simple docstring""" import argparse import struct import unittest class __snake_case : """simple docstring""" def __init__( self :Optional[Any] , UpperCamelCase__ :bytes ): _a = data # Initialize hash values _a = [ ...
388
"""simple docstring""" from __future__ import annotations import math def __a ( a, a ): """simple docstring""" _a = u for i in range(1, a ): _a = temp * (u - i) return temp def __a ( ): """sim...
388
1
def _snake_case ( ) -> list[list[int]]: '''simple docstring''' return [list(range(1_0_0_0 - i , -1_0_0_0 - i , -1 ) ) for i in range(1_0_0_0 )] __UpperCAmelCase = generate_large_matrix() __UpperCAmelCase = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1,...
716
"""simple docstring""" from __future__ import annotations class _SCREAMING_SNAKE_CASE : def __init__( self , __A=None ) -> Tuple: lowerCAmelCase_ :Optional[int] = data lowerCAmelCase_ :List[Any] = None ...
256
0
from functools import reduce snake_case_ : Any = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' '6689664895044524452316...
488
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def UpperCamelCase ( ) ->Optional[int]: _lowerCamelCase : int = ArgumentParser('''Diffusers CLI tool''' , usage='''diffusers-cli <command> [<args>]''' ) _lowerCamelCas...
434
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig a : Union[str, Any] = logging.get_logger(__name__) a : Dict = { '''Intel/dpt-large''': '''https://huggingface.co/Intel/dp...
701
"""simple docstring""" import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available...
31
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetu...
26
'''simple docstring''' import argparse import os import re import packaging.version __UpperCamelCase = "examples/" __UpperCamelCase = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init...
26
1
"""simple docstring""" def snake_case__ ( __lowerCamelCase : float , __lowerCamelCase : float , __lowerCamelCase : float , __lowerCamelCase : float , __lowerCamelCase : float , ): """simple docstring""" lowerCamelCase_...
625
"""simple docstring""" import colorsys from PIL import Image # type: ignore def snake_case__ ( __lowerCamelCase : float , __lowerCamelCase : float , __lowerCamelCase : int ): """simple docstring""" lowerCamelCase__ : Optional[Any] =x lowerC...
625
1
"""simple docstring""" import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __snake_case ( __A : Union[str, Any] , __A : Any , __A : Tuple , __A : Union[str, Any] , __A ...
265
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin...
265
1
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example snake_case = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ...
703
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm snake_case = 20_48 snake_case = 40_96 snake_case = 42 snake_case = os.environ.pop("""PROCESS_TRAIN""", """false""") snake_case = {"""null""": 0, """s...
568
0
import os from collections import deque import torch from torch.utils.data import Dataset class snake_case__(_UpperCamelCase ): """simple docstring""" def __init__( self : Tuple , SCREAMING_SNAKE_CASE : Optional[Any]="" , SCREAMING_SNAKE_CASE : Union[str, Any]="trai...
496
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def __lowerCamelCase ( lowerCamelCase__ ): """simple docstring""" lowercase__ : Optional[int] = [ "encoder.version", "decoder.version", "mode...
496
1
"""simple docstring""" import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base impor...
700
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase = logging.get_logger(__name__) low...
24
0
"""simple docstring""" class snake_case_ : """simple docstring""" def __init__( self , __a ): """simple docstring""" A__ = n A__ = [None] * self.n A__ = 0 # index of the first element A__ ...
260
"""simple docstring""" from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline SCREAMING_SNAKE_CASE : Tuple ...
260
1
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision...
512
'''simple docstring''' from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("""3.8"""): import importlib_metadata else: import importlib.metadata as importlib_...
512
1
"""simple docstring""" import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transfo...
49
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Any = { 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', '...
49
1
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """Visual-Attention-Network/van-base""": ( """https://huggingface.co/Visual-Attention-Network/van-base/blob/main/co...
702
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { ...
22
0
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class lowercase__ ( A__ ): a_ ="Wav2Vec2FeatureExtractor" a_ ...
339
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _lowercase : Dict ={"configuration_plbart": ["PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP", "P...
136
0
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters UpperCAmelCase = (720, 1280) # Height, Width UpperCAmelCase = (0.4, 0.6) # if height or width lower than this scale, drop it. UpperCAmelCase = 1 / 100 UpperCAmelCase ...
565
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): lowercase = set() # To detect a back edge, keep track of vertices currently in the recursion stack lowercase = set() return any( node not in visited and depth_first_search(__SCREAMING_SNAKE_CASE , __SCREAMING_SNA...
565
1
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : Dict ): """simple docstring""" if isinstance(__UpperCAmelCase , __UpperCAmelCase ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(__UpperCAmelCase ,...
561
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, _int...
194
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, S...
684
import os def SCREAMING_SNAKE_CASE__ ( ) -> Dict: with open(os.path.dirname(lowercase ) + """/grid.txt""" ) as f: snake_case : Tuple = [] # noqa: E741 for _ in range(20 ): l.append([int(lowercase ) for x in f.readline().split()] ) snake_cas...
684
1
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, Attn...
110
"""simple docstring""" from itertools import permutations def lowerCamelCase ( _snake_case ): 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 UpperCAmelCase__ : List[str] = ...
110
1
from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
701
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _UpperCamelCase: Optional[int] =TypeVar('T') class __lowercase( Generic[T] ): """simple docstring""" def __init__( self : str , _lowerCAmelCase : T ...
585
0
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef a__ : int = ( 'This metric will be removed fr...
51
def lowerCamelCase ( a_ ) -> list: lowerCAmelCase_ = len(a_ ) for _ in range(a_ ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: lowerCAmelCase_ , low...
318
0
def lowerCamelCase_ ( lowerCAmelCase: str )-> int: _snake_case : Any = hex_num.strip() if not hex_num: raise ValueError('No value was passed to the function' ) _snake_case : str = hex_num[0] == '-' if is_negative: _snake_case : List[str] ...
720
from functools import reduce lowerCAmelCase_ = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """66...
669
0
"""simple docstring""" from collections import Counter from timeit import timeit def A ( __snake_case: Optional[int] = "" , ) -> bool: """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values() )...
545
def lowercase ( ) -> int: return [ a * b * (1000 - a - b) for a in range(1 ,999 ) for b in range(_a ,999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if __name__ == "__main__": print(F"""{solution() = }""")
137
0
import re def UpperCamelCase_ ( lowerCAmelCase__ ): """simple docstring""" if len(re.findall("[ATCG]" , lowerCAmelCase__ ) ) != len(lowerCAmelCase__ ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) ...
587
from __future__ import annotations import math def UpperCamelCase_ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): """simple docstring""" if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not sc...
587
1
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 _SCREAMING_SNAKE_CASE ...
70
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowercase__ :List[Any] = Lock() def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase...
522
0
'''simple docstring''' import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from fla...
701
'''simple docstring''' import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_atten...
179
0
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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils import logging logging.set_ve...
221
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node a_ = 4 a_ = 3 class UpperCAmelCase__ ( snake_case ): """simple docstring""" ...
221
1
'''simple docstring''' 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, get_resize_output_image_size, normalize, rescale, resize, to_chan...
459
'''simple docstring''' # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tes...
459
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeat...
325
def _A ( _lowercase = 1_00 ) -> int: """simple docstring""" __UpperCamelCase = 0 __UpperCamelCase = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__main_...
1
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowerCamelCase...
711
'''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-smal...
686
0
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCAmelCase_ : List[str] = {"""configuration_dpt""": ["""DPT_PRETRAINED...
435
import warnings 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...
486
0
import operator as op def A__ ( lowerCamelCase ) -> Optional[int]: UpperCamelCase_: Optional[int] = [] UpperCamelCase_: Optional[int] = lambda lowerCamelCase , lowerCamelCase : int(x / y ) # noqa: E731 integer division operation UpperCame...
704
import random def A__ ( lowerCamelCase , lowerCamelCase , lowerCamelCase = False ) -> dict: UpperCamelCase_: dict = {i: [] for i in range(lowerCamelCase )} # if probability is greater or equal than 1, then generate a complete graph if probability ...
670
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule __magic_name__ : str = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import...
281
"""simple docstring""" import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common impor...
281
1
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def _snake_case (_snake_case : int = 3) -> qiskit.result.counts.Counts: if isinstance(_snake_case , _snake_case): raise TypeError('number ...
557
# 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 ...
557
1
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
691
"""simple docstring""" import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention,...
656
0
import os from pathlib import Path def A__ ( ): from torch.utils.cpp_extension import load SCREAMING_SNAKE_CASE__: int= Path(snake_case_ ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' SCREAMING_SNAKE_CASE__: Any= [ root / filename for filename in...
107
lowercase_ : Optional[int] = '0.18.2' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_librosa_availa...
107
1
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable a : Union[str, Any] = { '''configuration_gpt_neox_japanese''': ['''GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHI...
69
from math import factorial def UpperCamelCase ( snake_case__ , snake_case__): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter pos...
659
0
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE_ ): lowercase_ : Any = False while is_sorted is False: # Until all the indices are traversed keep looping lowercase_ : Any = True for i in range(0 , ...
438
'''simple docstring''' import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__ ( _snake_case , unittest.TestCase ): ...
438
1
"""simple docstring""" import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments __UpperCAmelCase = logging.getLogger(__name__) @dataclass class __lowercase...
65
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int ) -> None: '''simple docstring''' _UpperCAmelCase = generate_pascal_triangle(__lowercase ) for row_idx in range(__lowercase ): # Print left spaces for _ in range(num_rows - ro...
236
0
'''simple docstring''' def UpperCAmelCase ( lowerCamelCase_ :int ): '''simple docstring''' if num <= 0: raise ValueError("""Input must be a positive integer""" ) snake_case_ : List[str] = [True] * (num + 1) snake_case_ : str = 2 whil...
267
'''simple docstring''' # Copyright (c) 2021-, NVIDIA CORPORATION. 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...
267
1