code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
def UpperCamelCase_ ( a_ ) ->list[int]: A =len(a_ ) for i in range(a_ ): for j in range(i + 1 , a_ ): if numbers[j] < numbers[i]: A , A =numbers[j], numbers[i] return numbers if __name__ == "__main__": __a = input("""Enter numbers separated by a ...
689
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } __a ...
689
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = """▁""" __a ...
689
def UpperCamelCase_ ( a_ , a_ ) ->list[int]: A =int(a_ ) # Initialize Result A =[] # Traverse through all denomination for denomination in reversed(a_ ): # Find denominations while int(a_ ) >= int(a_ ): total_value -= int(a_ ) answer.append(a_ ) # Appen...
689
1
def UpperCamelCase_ ( a_ = 10**12 ) ->int: A =1 A =0 A =1 A =1 while numerator <= 2 * min_total - 1: prev_numerator += 2 * numerator numerator += 2 * prev_numerator prev_denominator += 2 * denominator denominator += 2 * prev_denominator return (denominator + 1) // 2...
689
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
689
1
# 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 applicab...
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 dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf __a = logging.get_logger(__name__) @dataclass class ...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { """configuration_roformer""": ["""ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RoFor...
689
1
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 __a = 0b10_11_00_11_11_10_11_00_10_01_00_00_01_11_10_11_10_11_00_01_10_01_11_10 # bin...
689
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __a = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", booktitle = \"Proceedings of the Tenth Wo...
689
1
def UpperCamelCase_ ( a_ , a_ ) ->float: if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(a_ ) * abs(a_ ) if __name__ == "__main__": import doctest doctest.testmod(verbose=True)
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __a = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: if not is_torch_available(): raise Opti...
689
1
import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as np from .import_utils impor...
689
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
689
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __a = {"""configuration_fnet""": ["""FNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FNetConfig"""]} try: if not ...
689
from __future__ import annotations def UpperCamelCase_ ( a_ ) ->None: create_state_space_tree(a_ , [] , 0 , [0 for i in range(len(a_ ) )] ) def UpperCamelCase_ ( a_ , a_ , a_ , a_ , ) ->None: if index == len(a_ ):...
689
1
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def UpperCamelCase_ ( ) ->Union[str, Any]: import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname f...
689
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.testi...
689
1
import numpy as np import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel from ...utils import logging __a = logging.get_logger(__name__) class UpperCamelCase__( lowerCAmelCase__ ): """simple docstring""" _A = CLIPConfig...
689
import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init ...
689
1
from importlib import import_module from .logging import get_logger __a = get_logger(__name__) class UpperCamelCase__: """simple docstring""" def __init__( self : Union[str, Any] , snake_case__ : Tuple , snake_case__ : Union[str, Any]=None ): """simple docst...
689
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase__: """simple docstring""" _A = 42 _A = None _A = None __a = namedtuple("""CoinsDistribResult""", """moves excess""") def UpperCamelCase...
689
1
import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class UpperCamelCase__: """simple docstring""" def __init__( self : List[Any] , snake_case__ : Tuple , snake_case__ : int , snake_case__ : int ): """simple docstring""" if ds...
689
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a ...
689
1
def UpperCamelCase_ ( a_ , a_ ) ->int: return 1 if input_a == input_a else 0 def UpperCamelCase_ ( ) ->None: assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 , 1 ) == 1 ...
689
def UpperCamelCase_ ( a_ = 6008_5147_5143 ) ->int: try: A =int(a_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be greater than or equal to one." ) A =2 A =0 if n == 2: r...
689
1
from collections import deque def UpperCamelCase_ ( a_ ) ->List[str]: A =len(a_ ) A =deque() A =[False for _ in range(a_ )] A =[-1 for _ in range(a_ )] A =index_of[:] def strong_connect(a_ , a_ , a_ ): A =index # the number when this node is seen ...
689
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class UpperCamelCase__( lowerCAmelCase__ ): """simple docstring""" _A = "W...
689
1
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequenceClassification, DataCol...
689
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
689
1
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 __a = { # 1536-bit 5: { """prime""": int( """FFFFFFFFFFFFFFFFC...
689
# 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 the...
689
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { """configuration_whisper""": ["""WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Whisper...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __a = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileViTConfig""", """MobileV...
689
1
import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_available, is_vision_available f...
689
def UpperCamelCase_ ( a_ , a_ ) ->int: return int((input_a, input_a).count(0 ) != 0 ) def UpperCamelCase_ ( ) ->None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gate(1 , ...
689
1
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 UpperCamelCase__( lowerCAmelCase__ ): """simple docstring"...
689
def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: def count_of_possible_combinations(a_ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) return count_of_possible_combinati...
689
1
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_optuna, default_hp...
689
from __future__ import annotations import math def UpperCamelCase_ ( a_ , a_ ) ->float: A =u for i in range(1 , a_ ): A =temp * (u - i) return temp def UpperCamelCase_ ( ) ->None: A =int(input("enter the numbers of values: " ) ) A =[] for _ in ...
689
1
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) __a = _symbol_database.Default...
689
from cva import destroyAllWindows, imread, imshow, waitKey def UpperCamelCase_ ( a_ ) ->Any: # getting number of pixels in the image A , A =img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(a_ ): for j in range(a_ ): A =[255, 255, 255]...
689
1
from datetime import datetime as dt import os from github import Github __a = [ """good first issue""", """good second issue""", """good difficult issue""", """feature request""", """new model""", """wip""", ] def UpperCamelCase_ ( ) ->Union[str, Any]: A =Github(o...
689
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } __a ...
689
1
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class UpperCamelCase__( lowerCAmelCase__ , lowerCAmelCase__ ): """simple docstring""" @register_to_config def __init...
689
def UpperCamelCase_ ( a_ , a_ ) ->list[int]: A =int(a_ ) # Initialize Result A =[] # Traverse through all denomination for denomination in reversed(a_ ): # Find denominations while int(a_ ) >= int(a_ ): total_value -= int(a_ ) answer.append(a_ ) # Appen...
689
1
from typing import Any import numpy as np def UpperCamelCase_ ( a_ ) ->bool: return np.array_equal(a_ , matrix.conjugate().T ) def UpperCamelCase_ ( a_ , a_ ) ->Any: A =v.conjugate().T A =v_star.dot(a_ ) assert isinstance(a_ , np.ndarray ) ret...
689
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
689
1
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTeste...
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
import collections import importlib.util import os import re from pathlib import Path __a = """src/transformers""" # Matches is_xxx_available() __a = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} __a = re.compile(r"""^_import_structure\s+=...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { """configuration_roformer""": ["""ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RoFor...
689
1
def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: if exponent == 1: return base if exponent % 2 == 0: A =_modexpt(a_ , exponent // 2 , a_ ) % modulo_value return (x * x) % modulo_value else: return (base * _modexpt(a_ , exponent - 1 ...
689
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __a = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", booktitle = \"Proceedings of the Tenth Wo...
689
1
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class UpperCamelCase__( nn.Module ): """simple docstring""" def __init__( self : int , snake_case__ : int = 16 , snake_case__ : int = 88 , sn...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __a = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: if not is_torch_available(): raise Opti...
689
1
from pathlib import Path import numpy as np from PIL import Image def UpperCamelCase_ ( a_ ) ->np.ndarray: A , A , A =rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.2989 * r + 0.5870 * g + 0.1140 * b def UpperCamelCase_ ( a_ ) ->np.ndarray: return (gray > 127) & (gray ...
689
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
689
1
from __future__ import annotations def UpperCamelCase_ ( a_ , a_ , a_ ) ->int | float: if len(a_ ) == 0: raise ValueError("find_max() arg is an empty sequence" ) if ( left >= len(a_ ) or left < -len(a_ ) or right >= len(a_ ) or right < -len(a_ ) ...
689
from __future__ import annotations def UpperCamelCase_ ( a_ ) ->None: create_state_space_tree(a_ , [] , 0 , [0 for i in range(len(a_ ) )] ) def UpperCamelCase_ ( a_ , a_ , a_ , a_ , ) ->None: if index == len(a_ ):...
689
1
from graphs.minimum_spanning_tree_kruskal import kruskal def UpperCamelCase_ ( ) ->Tuple: A =9 A =[ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], [8, 6, 6], [2, 3, 7], [2, 5, 4], [6, 5, 2], [3, 5, 14], [3, ...
689
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.testi...
689
1
def UpperCamelCase_ ( a_ ) ->bool: return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def UpperCamelCase_ ( a_ ) ->bool: A =credit_card_number A =0 A =len(a_ ) - 2 for i in range(a_ , -1 , -2 ): # double the value of every sec...
689
import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init ...
689
1
import re import string import numpy as np import datasets __a = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ __a = """ Args: predictions: List of predicted texts. refer...
689
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase__: """simple docstring""" _A = 42 _A = None _A = None __a = namedtuple("""CoinsDistribResult""", """moves excess""") def UpperCamelCase...
689
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import MC...
689
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a ...
689
1
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
689
def UpperCamelCase_ ( a_ = 6008_5147_5143 ) ->int: try: A =int(a_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be greater than or equal to one." ) A =2 A =0 if n == 2: r...
689
1
def UpperCamelCase_ ( a_ ) ->list[list[float]]: A =[] for data in source_data: for i, el in enumerate(a_ ): if len(a_ ) < i + 1: data_lists.append([] ) data_lists[i].append(float(a_ ) ) return data_lists def UpperCamelCase_ ( a_ , a_ ) ->list[li...
689
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class UpperCamelCase__( lowerCAmelCase__ ): """simple docstring""" _A = "W...
689
1
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { """microsoft/xprophetnet-large-wiki100-cased""": ( """https://huggingface.co/microsoft/xprophetnet-large-wiki100...
689
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
689
1
def UpperCamelCase_ ( a_ ) ->list: if len(a_ ) < 2: return collection def circle_sort_util(a_ , a_ , a_ ) -> bool: A =False if low == high: return swapped A =low A =high while left < right: if collection[left] > collection[right]: ...
689
# 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 the...
689
1
from collections import defaultdict from math import ceil, sqrt def UpperCamelCase_ ( a_ = 100_0000 , a_ = 10 ) ->int: A =defaultdict(a_ ) for outer_width in range(3 , (t_limit // 4) + 2 ): if outer_width * outer_width > t_limit: A =max( ceil(sqrt(outer_...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __a = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileViTConfig""", """MobileV...
689
1
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient __a = WebClient(token=os.environ["""CI_SLACK_BOT_TOKEN"""]) def UpperCamelCase_ ( a_ ) ->Optional[Any]: A =test_...
689
def UpperCamelCase_ ( a_ , a_ ) ->int: return int((input_a, input_a).count(0 ) != 0 ) def UpperCamelCase_ ( ) ->None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gate(1 , ...
689
1
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://huggingface.co/facebook/xlm-r...
689
def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: def count_of_possible_combinations(a_ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) return count_of_possible_combinati...
689
1
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampling f...
689
from __future__ import annotations import math def UpperCamelCase_ ( a_ , a_ ) ->float: A =u for i in range(1 , a_ ): A =temp * (u - i) return temp def UpperCamelCase_ ( ) ->None: A =int(input("enter the numbers of values: " ) ) A =[] for _ in ...
689
1
import torch from transformers import AutoModel class UpperCamelCase__( torch.nn.Module ): """simple docstring""" def __init__( self : List[Any] , snake_case__ : Dict="sayef/fsner-bert-base-uncased" ): """simple docstring""" super(snake_case__ , self ).__init__...
689
from cva import destroyAllWindows, imread, imshow, waitKey def UpperCamelCase_ ( a_ ) ->Any: # getting number of pixels in the image A , A =img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(a_ ): for j in range(a_ ): A =[255, 255, 255]...
689
1
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. __a = 1_0 def UpperCamelCase_ ( a_ , a_ , a_ , a_ ) ->int: for i in range(a_ , ...
689
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } __a ...
689
1
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from datase...
689
def UpperCamelCase_ ( a_ , a_ ) ->list[int]: A =int(a_ ) # Initialize Result A =[] # Traverse through all denomination for denomination in reversed(a_ ): # Find denominations while int(a_ ) >= int(a_ ): total_value -= int(a_ ) answer.append(a_ ) # Appen...
689
1
import argparse from collections import defaultdict def UpperCamelCase_ ( a_ , a_ , a_ , a_ , a_ ) ->Optional[Any]: A =f'''{file}_{class_name}_{test_name}''' done_test[_id] += 1 with open(a_ , "r" ) as f: A =f.readlines() A =f'''class...
689
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
689
1
def UpperCamelCase_ ( a_ = 5000_0000 ) ->int: A =set() A =int((limit - 24) ** (1 / 2) ) A =set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): if p not in primes: continue p...
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
import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init ...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { """configuration_roformer""": ["""ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RoFor...
689
1
from math import ceil, sqrt def UpperCamelCase_ ( a_ = 100_0000 ) ->int: A =0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: A =max(ceil(sqrt(outer_width**2 - limit ) ) , 1 ) else: A =1 if (outer_width - hole_width_lo...
689
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __a = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", booktitle = \"Proceedings of the Tenth Wo...
689
1
from ...processing_utils import ProcessorMixin class UpperCamelCase__( lowerCAmelCase__ ): """simple docstring""" _A = "SpeechT5FeatureExtractor" _A = "SpeechT5Tokenizer" def __init__( self : int , snake_case__ : Union[str, Any] , snake_case__ : Tuple ...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __a = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: if not is_torch_available(): raise Opti...
689
1
from argparse import ArgumentParser from .env import EnvironmentCommand def UpperCamelCase_ ( ) ->int: A =ArgumentParser("Diffusers CLI tool" , usage="diffusers-cli <command> [<args>]" ) A =parser.add_subparsers(help="diffusers-cli command helpers" ) # Register commands Environme...
689
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
689
1
from typing import List import numpy as np def UpperCamelCase_ ( a_ ) ->int: A ={key: len(a_ ) for key, value in gen_kwargs.items() if isinstance(a_ , a_ )} if len(set(lists_lengths.values() ) ) > 1: raise RuntimeError( ( "Sharding is ambiguous for this datase...
689
from __future__ import annotations def UpperCamelCase_ ( a_ ) ->None: create_state_space_tree(a_ , [] , 0 , [0 for i in range(len(a_ ) )] ) def UpperCamelCase_ ( a_ , a_ , a_ , a_ , ) ->None: if index == len(a_ ):...
689
1
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.utils i...
689
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.testi...
689
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __a = { """configuration_convnext""": ["""CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ConvNextConfig""", """ConvNextOn...
689
import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init ...
689
1
import os 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_pegasus import PegasusTokenizer else: __a = None _...
689
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase__: """simple docstring""" _A = 42 _A = None _A = None __a = namedtuple("""CoinsDistribResult""", """moves excess""") def UpperCamelCase...
689
1
import string import numpy def UpperCamelCase_ ( a_ , a_ ) ->int: return b if a == 0 else greatest_common_divisor(b % a , a_ ) class UpperCamelCase__: """simple docstring""" _A = string.ascii_uppercase + string.digits # This cipher takes alphanumerics into account ...
689
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a ...
689
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __a = r""" [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the documentation...
689
def UpperCamelCase_ ( a_ = 6008_5147_5143 ) ->int: try: A =int(a_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be greater than or equal to one." ) A =2 A =0 if n == 2: r...
689
1
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() __a = logging.get_logger("""transformers.models.speecht5""") def UpperCamelCase_ ( a_ , a_ , a_ ) ->Any: hf_model.appl...
689
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class UpperCamelCase__( lowerCAmelCase__ ): """simple docstring""" _A = "W...
689
1
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def UpperCamelCase_ ( a_ ) ->List[str]: # vision encoder if "img_encoder.pos_embed" in name: A =name.replace("img_encoder.pos_embed" , "vision_mod...
689
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
689
1
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, blenderbot, blenderbot...
689
# 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 the...
689
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def UpperCamelCase_ ( ) ->Union[str, Any]: A =ArgumentParser( description=( "PyTorch TPU distributed training launch helper utili...
689
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __a = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileViTConfig""", """MobileV...
689
1
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() __a = logging.get_logger(__name__) __a = { """post_extract_proj""": """feature_projection.projection""", """en...
689
def UpperCamelCase_ ( a_ , a_ ) ->int: return int((input_a, input_a).count(0 ) != 0 ) def UpperCamelCase_ ( ) ->None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gate(1 , ...
689
1
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
689
def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: def count_of_possible_combinations(a_ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) return count_of_possible_combinati...
689
1
from __future__ import annotations def UpperCamelCase_ ( a_ ) ->None: create_state_space_tree(a_ , [] , 0 , [0 for i in range(len(a_ ) )] ) def UpperCamelCase_ ( a_ , a_ , a_ , a_ , ) ->None: if index == len(a_ ):...
689
from __future__ import annotations import math def UpperCamelCase_ ( a_ , a_ ) ->float: A =u for i in range(1 , a_ ): A =temp * (u - i) return temp def UpperCamelCase_ ( ) ->None: A =int(input("enter the numbers of values: " ) ) A =[] for _ in ...
689
1
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, JumanppTokenizer,...
689
from cva import destroyAllWindows, imread, imshow, waitKey def UpperCamelCase_ ( a_ ) ->Any: # getting number of pixels in the image A , A =img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(a_ ): for j in range(a_ ): A =[255, 255, 255]...
689
1
from scipy.stats import spearmanr import datasets __a = """ The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Positive correlations imply that as dat...
689
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } __a ...
689
1
import argparse import copy def UpperCamelCase_ ( a_ ) ->Tuple: A ={} with open(SCREAMING_SNAKE_CASE_ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: A =[] _list.append([line.split()[1], line.split()[2]] ) A =_list els...
700
def UpperCamelCase_ ( a_ , a_ ) ->list[int]: A =int(a_ ) # Initialize Result A =[] # Traverse through all denomination for denomination in reversed(a_ ): # Find denominations while int(a_ ) >= int(a_ ): total_value -= int(a_ ) answer.append(a_ ) # Appen...
689
0
def UpperCamelCase_ ( a_ , a_ , a_ ) ->Optional[Any]: def count_of_possible_combinations(a_ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) return count_of_possible...
701
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
689
0
'''simple docstring''' def UpperCamelCase_ ( a_ ) ->int: A =1 A =2 while i * i <= n: A =0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors *= 2 return n_divisors def UpperCamelCase_ ( ) ...
702
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
0
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 from ......
703
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { """configuration_roformer""": ["""ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RoFor...
689
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = {'''configuration_timm_backbone''': ['''TimmBackboneConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
704
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __a = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", booktitle = \"Proceedings of the Tenth Wo...
689
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { "microsoft/wavlm-base": "https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json", # See all WavLM models at https:...
705
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __a = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: if not is_torch_available(): raise Opti...
689
0
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState, PartialState from...
706
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
689
0
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_available...
707
from __future__ import annotations def UpperCamelCase_ ( a_ ) ->None: create_state_space_tree(a_ , [] , 0 , [0 for i in range(len(a_ ) )] ) def UpperCamelCase_ ( a_ , a_ , a_ , a_ , ) ->None: if index == len(a_ ):...
689
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { """asapp/sew-d-tiny-100k""": """https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json""", # See all SEW-D models...
708
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.testi...
689
0
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( Auto...
709
import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init ...
689
0
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impor...
710
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase__: """simple docstring""" _A = 42 _A = None _A = None __a = namedtuple("""CoinsDistribResult""", """moves excess""") def UpperCamelCase...
689
0
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, TFBaseModelOutputWith...
711
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a ...
689
0
__a = {} def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: return 0 # if we have no days left, and have not failed any other rules, # we have...
712
def UpperCamelCase_ ( a_ = 6008_5147_5143 ) ->int: try: A =int(a_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be greater than or equal to one." ) A =2 A =0 if n == 2: r...
689
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils imp...
713
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class UpperCamelCase__( lowerCAmelCase__ ): """simple docstring""" _A = "W...
689
0
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedulers.scheduling_ddpm i...
714
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
689
0
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): import torch...
715
# 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 the...
689
0
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configurati...
716
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __a = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileViTConfig""", """MobileV...
689
0
'''simple docstring''' import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __a = models.Sequential() # Step 1 - Conv...
717
def UpperCamelCase_ ( a_ , a_ ) ->int: return int((input_a, input_a).count(0 ) != 0 ) def UpperCamelCase_ ( ) ->None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gate(1 , ...
689
0
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class UpperCamelCase__( nn.Module ): """simple docstring""" _A = 4_2 _A = 4_2 _A = 0.0 _A = 1 _A =...
718
def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: def count_of_possible_combinations(a_ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) return count_of_possible_combinati...
689
0
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 from transformers.utils import ...
719
from __future__ import annotations import math def UpperCamelCase_ ( a_ , a_ ) ->float: A =u for i in range(1 , a_ ): A =temp * (u - i) return temp def UpperCamelCase_ ( ) ->None: A =int(input("enter the numbers of values: " ) ) A =[] for _ in ...
689
0
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_transformers.convert_switch_tr...
720
from cva import destroyAllWindows, imread, imshow, waitKey def UpperCamelCase_ ( a_ ) ->Any: # getting number of pixels in the image A , A =img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(a_ ): for j in range(a_ ): A =[255, 255, 255]...
689
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_big_bird impor...
721
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } __a ...
689
0
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __a = True except Im...
700
def UpperCamelCase_ ( a_ , a_ ) ->list[int]: A =int(a_ ) # Initialize Result A =[] # Traverse through all denomination for denomination in reversed(a_ ): # Find denominations while int(a_ ) >= int(a_ ): total_value -= int(a_ ) answer.append(a_ ) # Appen...
689
0
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import o...
701
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
689
0
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def UpperCamelCase_ ( a_ , a_ , a_ , a_ , a_ ) ->Optional[Any]: A =StableDiffusionPipeline.from_pretrained(a_ , ...
702
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
0
import inspect import unittest from transformers import MobileViTConfig 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_configuration_common import ConfigTester from ...test_...
703
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { """configuration_roformer""": ["""ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RoFor...
689
0
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # Copied from diffusers.sched...
704
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __a = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", booktitle = \"Proceedings of the Tenth Wo...
689
0
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available(): import torch from ..mo...
705
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __a = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: if not is_torch_available(): raise Opti...
689
0
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCamelCase__( yaml.SafeLoader ): """simple docstring""" def _a ( self : Union[str, Any] , snake_case__ : Any ): """simple docstring""" A =[self.c...
706
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
689
0
from manim import * class UpperCamelCase__( lowerCAmelCase__ ): """simple docstring""" def _a ( self : int ): """simple docstring""" A =Rectangle(height=0.5 , width=0.5 ) A =Rectangle(height=0.46 , width=0.46 ).set_stroke(width=0 ) A =[mem.cop...
707
from __future__ import annotations def UpperCamelCase_ ( a_ ) ->None: create_state_space_tree(a_ , [] , 0 , [0 for i in range(len(a_ ) )] ) def UpperCamelCase_ ( a_ , a_ , a_ , a_ , ) ->None: if index == len(a_ ):...
689
0
import sys __a = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121722383113" ...
708
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.testi...
689
0
def UpperCamelCase_ ( a_ ) ->float: if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) A =sum(_lowercase ) / len(_lowercase ) # Calculate the average return sum(abs(x - average ) for x in nums ) / len(_lowercase ) if __name__...
709
import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init ...
689
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { '''SCUT-DLVCLab/lilt-roberta-en-base''': ( '''https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json''' ), } class Upp...
710
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase__: """simple docstring""" _A = 42 _A = None _A = None __a = namedtuple("""CoinsDistribResult""", """moves excess""") def UpperCamelCase...
689
0