code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( ...
69
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence __snake_case =...
69
1
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets.util...
705
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Any = logging.get_logger(__name__) __lowerCAmelCase : Dict = { 'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/config.json', 'funne...
164
0
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def UpperCAmelCase_ ( snake_case__ ) -> str: """simple docstring""" lowerCAmelCase__ = [ 'decoder.version', 'decoder.out...
193
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def __lowerCamelCase ( _lowercase , _lowercase , _lowercase , _lowercase=1024 ) -> Union[str, Any]: UpperCamelCase , UpperCamelCase ...
282
0
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging...
508
'''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, ...
508
1
import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL _a : Optional[int] = version.parse(version.parse(torch.__version__).base_version) < version.parse('1.11') def UpperCamelCase__ ( _A...
479
import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem from .utils import require_lza, require...
479
1
from math import factorial def UpperCamelCase_( _A :int = 1_00 )-> int: return sum(map(_A , str(factorial(_A ) ) ) ) if __name__ == "__main__": print(solution(int(input('Enter the Number: ').strip())))
185
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCamelCase__ ( UpperCAmelCase ): """simple docstring""" @staticmethod @abstractmethod def snake_case__ ( snake_case ): '''simple docstring''' raise NotImp...
185
1
"""simple docstring""" 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 i...
77
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_: int = { 'configuration_lxmert': ['LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LxmertC...
648
0
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_v...
701
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def UpperCamelCase (*lowercase_: Optional[int] , lowercase_: Optional[Union[Dict, Any]] = None , lowercase_: Dict=True , lowercase_: Tuple=2 ) -> Dict: from .. imp...
64
0
import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, requi...
500
from __future__ import annotations class UpperCAmelCase_ : def __init__( self, __a, __a): '''simple docstring''' _lowerCAmelCase , _lowerCAmelCase : Optional[int] = text, pattern _lowerCAmelCase , _lowerCAme...
500
1
"""simple docstring""" import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( ...
598
"""simple docstring""" import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_...
598
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json' ), # See all ...
464
import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCriteria, MaxNewTokensCriteria...
464
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...test_pip...
721
from queue import PriorityQueue from typing import Any import numpy as np def lowerCAmelCase__(__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,) -> float | int: '''simple docstring''' for nxt, d in graph[v]...
29
0
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test_...
74
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class __UpperCamelCa...
74
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { "shi-labs/dinat-min...
708
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) lowerCAmelCase__ = models.Sequential() # Step 1 - Con...
594
0
import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = '''T5Config''' def A (...
9
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A_ : List[str] ={ """configuration_graphormer""": ["""GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GraphormerConfig"""], } ...
716
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def SCREAMING_SNAKE_CASE_ ( )-> Generator[int, None, None]: _lowerCamelCase = {} _lowerCamelCase = 2 while True: _lowerCamelCase = fact...
222
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowercase_ : List[str] = { '''configuration_longt5''': ['''LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LongT5Config''', '''LongT5OnnxConfig...
304
def A__( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__lowerCAmelCase ) ) def A__( __lowerCAmelCase , __lowerCAmelCase , ...
304
1
import string def A ( snake_case__ : str ) -> None: '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): __snake_case = '' for symbol in message: if symbol in string.ascii_uppercase: __snake_case = string.asc...
676
import numpy as np def A ( snake_case__ : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def A ( snake_case__ : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sigmoid(s...
676
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case : Any = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig""...
545
"""simple docstring""" def A ( __snake_case: int = 1_0_0_0_0_0_0 ) -> int: """simple docstring""" __magic_name__ = limit + 1 __magic_name__ = [0] * limit for first_term in range(1 , __snake_case ): ...
545
1
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.training.common_utils impor...
402
from collections import deque from math import floor from random import random from time import time class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self : Any ) -> int: """simple docstring""" _UpperCAmelCase = {} def lowerCamelCase ...
402
1
"""simple docstring""" from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , ): """simple docstring""" lowe...
644
"""simple docstring""" import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __lowerCAmelCase : Optional[Any] = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation ...
644
1
'''simple docstring''' from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES lowercase_ = logging.get_logger(__name__) lowercase_ = OrderedDict( ...
352
'''simple docstring''' lowercase_ = 256 # Modulus to hash a string lowercase_ = 1_000_003 def lowerCAmelCase (__A , __A): """simple docstring""" _a = len(__A) _a = len(__A) if p_len > t_len: return False _a ...
352
1
import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def SCREAMING_SNAKE_CASE__ ( snak...
67
import requests lowercase_ = """YOUR API KEY""" def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = giphy_api_key ) -> list: lowercase__ = '+'.join(query.split() ) lowercase__ = F"""https://api.giphy.co...
235
0
'''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, Wava...
720
'''simple docstring''' import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def __UpperCAmelCase ( lowe...
6
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case : Optional[int] = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_available(): ...
53
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, requ...
141
0
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE_ ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" _a = (KDPMaDiscreteScheduler,) _a = ...
716
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np a_ : Tuple = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 a_ : List[str] = typing.Union[np.floataa, int, float] # noqa: UP007 def _...
678
0
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 = {"vocab_file": "...
68
'''simple docstring''' import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_availab...
459
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig snake_case_ = logging.get_logger(__name__) snake_case_ = { """Intel/dpt-large""": """https://huggingface.co/Intel/dpt-large/resolve/main/config.json"""...
700
'''simple docstring''' from ..utils import DummyObject, requires_backends class a__ ( metaclass=_lowercase ): __magic_name__ : List[Any] = ["sentencepiece"] def __init__(self : Optional[Any], *__UpperCAmelCase : List[Any], **__UpperCAmelCase : List[Any] ) -> Optional[in...
355
0
"""simple docstring""" from manim import * class UpperCAmelCase_ ( snake_case ): def _lowerCamelCase ( self ) -> List[str]: __lowercase : Tuple = Rectangle(height=0.5 , width=0.5 ) __lowercase : Tuple = ...
76
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Ac...
15
0
'''simple docstring''' import math import random def __magic_name__( lowerCamelCase, lowerCamelCase = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value _UpperCAmelCase : Union[str, Any] ...
710
'''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 ( ConditionalDetrConfig, ConditionalDetrForObjectDetectio...
474
0
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): import os...
547
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' def __init__( ...
547
1
import argparse import collections import json import os import re import string import sys import numpy as np __snake_case :Dict =re.compile(r'\b(a|an|the)\b', re.UNICODE) __snake_case :Optional[int] =None def lowerCamelCase_ ( ) -> List[Any]: '''simple docstring''...
715
import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py __snake_case :Tuple ='src/transformers' __snake_case ...
224
0
"""simple docstring""" class lowercase__ : '''simple docstring''' def __init__( self : Any ) -> List[Any]: '''simple docstring''' UpperCAmelCase_ = {} def lowercase__ ( ...
82
"""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_common...
200
0
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutp...
713
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __lowercase : Optional[Any] = { "configuration_falcon": ["FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP", "FalconConfig"], } ...
93
0
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def _A ( SCREAMING_SNAKE_CASE__ : Dict ): UpperCamelCase :List[Any] = [ '''encoder.version''', '''decoder.version''', ...
658
def _A ( SCREAMING_SNAKE_CASE__ : int ): if length <= 0 or not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): raise ValueError('''Length must be a positive integer.''' ) return [n * (2 * n - 1) for n in range(SCREAMING_SNAKE_CASE__ )] if __name__ ==...
658
1
import argparse import os from accelerate.test_utils import execute_subprocess_async def _lowercase ( _UpperCAmelCase=None ) -> Optional[int]: if subparsers is not None: lowerCamelCase =subparsers.add_parser("""test""" ) else: lowerCamelCase =argpars...
704
import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoint UpperCAmelCase__ ...
269
0
from __future__ import annotations from typing import Generic, TypeVar lowercase_ = TypeVar("""T""") class __UpperCamelCase ( Generic[T] ): """simple docstring""" def __init__( self : Optional[int] , _A : T ): """simp...
74
from __future__ import annotations def UpperCamelCase__ ( SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , ) -> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("""You cannot supply more ...
287
0
from __future__ import annotations def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase ) -> list[list[int]]: lowerCamelCase__ : list[list[int]] = [] lowerCamelCase__ : list[int] = [] lowerCamelCase__ : Optional[Any] = 0 lowerCame...
707
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import Fla...
188
0
from cva import destroyAllWindows, imread, imshow, waitKey def lowerCamelCase_ ( _UpperCamelCase ) -> str: """simple docstring""" snake_case_ , snake_case_ : Tuple = img.shape[0], img.shape[1] # converting each pixel's color to its negative ...
60
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, Sta...
361
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
718
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning things...
131
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : List[Any] = logging.get_logger(__name__) lowercase : Dict = { "facebook/xglm-564M": "https://huggingface.co/facebook/xglm-564M/resolve/main/config.json", # See all...
495
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-...
495
1
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake UpperCAmelCase_ = numpy.array([0, 0]) UpperCAmelCase_ = numpy.array([0.5, 0.8660254]) UpperCAmelCase_ = numpy.array([1, 0]) UpperCAmelCase_ = [VECTOR_1, ...
710
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 UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = ...
519
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_t...
501
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Union[str, Any] = { "configuration_b...
564
0
"""simple docstring""" from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class _lowercase : pass
712
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ : Any = {"""configuration_reformer""": ["""REFORMER_PRETRA...
497
0
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_torch, slow...
272
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BlipConfig'...
272
1
from random import shuffle import tensorflow as tf from numpy import array def snake_case ( UpperCAmelCase : Any, UpperCAmelCase : Any ): A = int(UpperCAmelCase ) assert noofclusters < len(UpperCAmelCase ) # Find out the dimensionality A = l...
110
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def snake_case ( UpperCAmelCase : List[Any] ): A = [ 'encoder.version', 'decoder.version', 'model.encoder.version', ...
110
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : str = { 'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce...
0
'''simple docstring''' import fire from utils import calculate_rouge, save_json def lowerCAmelCase_ ( snake_case__ , snake_case__ , snake_case__=None , **snake_case__ ): '''simple docstring''' A : Optional[Any] = [...
634
0
'''simple docstring''' import re def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: Optional[int] ): '''simple docstring''' if len(re.findall("[ATCG]" , lowerCAmelCase_ ) ) != len(lowerCAmelCase_ ): raise ValueError("Invalid Strand" ) return dna.translate(dna.ma...
707
import string import numpy def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int , __lowerCamelCase: int ): '''simple docstring''' return b if a == 0 else greatest_common_divisor(b % a , __lowerCamelCase ) class __lowerCamelCase : """simple docstring"...
601
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tp...
92
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() SCREAMING_SNAKE_CASE_ = ...
237
0
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ......
701
'''simple docstring''' import argparse import datetime def _lowerCAmelCase( UpperCAmelCase_ : str ) -> str: lowerCAmelCase__ = { """0""": """Sunday""", """1""": """Monday""", """2""": """Tuesday""", """3""": """Wedne...
211
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Tuple = logging.get_logger(__name__) UpperCAmelCase : List[Any] = { """MIT/ast-finetuned-audioset-10-10-0.4593""": ( """https://huggingface.co/MIT/ast-fine...
627
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ : Any = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CON...
79
0
'''simple docstring''' import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --...
710
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : Optional[int] = logging.get_logger(__name__) _lowerCAmelCase : Any = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-...
694
0
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
25
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __UpperCAmelCase ( __magic_name_...
653
0
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_p...
704
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: lowerCAmelCase_ : Any = None try: import msvcrt except ImportError: lowerCAmelCase_ : Union[str, Any] = None try: import fcntl except Import...
204
0
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is...
402
'''simple docstring''' from __future__ import annotations import os from collections.abc import Mapping _SCREAMING_SNAKE_CASE = tuple[int, int] class _lowerCAmelCase : """simple docstring""" def __init__( self : List[Any] , ...
369
0
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @requir...
346
from collections.abc import Generator from math import sin def __snake_case ( _UpperCamelCase ) -> bytes: if len(_UpperCamelCase ) != 32: raise ValueError('''Input must be of length 32''' ) _a = b'''''' for i in [3, 2, 1, 0]: little_endian += string_aa[8 * i : 8 * ...
346
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase_ = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxConfig"""]} ...
92
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a__ : int = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxConfig"""]} try: if not is_visio...
165
0
import requests __A : Union[str, Any] = """YOUR API KEY""" def __UpperCamelCase ( _A : Dict , _A : Dict = giphy_api_key ) ->list: """simple docstring""" lowerCamelCase_ ="+".join(query.split() ) lowerCamelCase_ ...
718
from ..utils import DummyObject, requires_backends class _SCREAMING_SNAKE_CASE ( metaclass=lowerCAmelCase__): _UpperCamelCase:List[Any] = ["torch", "torchsde"] def __init__( self , *_SCREAMING_SNAKE_CASE , **_SCREAMING_SNAKE_CASE )-> List[Any]: requires_bac...
75
0
import argparse A__: List[Any] = '''docs/source/_static/js/custom.js''' def lowerCAmelCase_ ( A_): with open(A_ ,encoding="utf-8" ,newline="\n") as f: UpperCamelCase__: Tuple = f.readlines() UpperCamelCase__: Dict = 0 # First let's p...
380
def lowerCAmelCase_ ( A_): 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") UpperCamelCase__: List[Any] = "" ...
380
1
import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer _lowerCamelCase = logging.g...
709
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCAmelCase__ ( UpperCAmelCase__ ): ...
321
0
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): ...
652
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = { "configuration_roformer":...
28
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase = {} try: if not is_sentencepiece_available(): raise Op...
702
"""simple docstring""" import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _UpperCamelCase = logging.get_logger("""transformers.models.speecht5""") def _a ( _snake_case , _snake_case , _...
74
0
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionMo...
56
'''simple docstring''' from __future__ import annotations from typing import Any def _a (lowercase__ : list ) -> int: """simple docstring""" if not postfix_notation: return 0 __snake_case = {'+', '-', '*', '/'} __snake_case = ...
56
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_u...
524
"""simple docstring""" from itertools import permutations def A__ ( UpperCamelCase ): 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 A = [7, 11...
524
1
'''simple docstring''' import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() A__ : Union[str, Any] = [ """...
13
'''simple docstring''' A__ : dict[tuple[int, int, int], int] = {} def UpperCAmelCase__ ( UpperCAmelCase_ : int , UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: # if we are absent twice, or late 3 consecutive days, ...
13
1
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py _UpperCamelCase : Optional[int] = 'src/diffusers' # Matches is_xxx_available() _UpperCamelCase : st...
704
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWaterma...
134
0
"""simple docstring""" import re from filelock import FileLock try: import nltk __magic_name__ = True except (ImportError, ModuleNotFoundError): __magic_name__ = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) ...
155
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
155
1
'''simple docstring''' import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import T...
706
'''simple docstring''' _A : Optional[Any] ='''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/''' def __UpperCamelCase ( _lowercase ) -> bytes: # Make sure the supplied data is a bytes-like object if not isinstance(_lowercase, _lowercase ): _lo...
4
0
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _snake_case : Optional[Any] = False class a (unittest.TestCase ): """simple docstrin...
81
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __SCREAMING_SNAKE_CASE : str =0 __SCREAMING_SNAKE_CASE : int =[ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, ...
428
0
import argparse import struct import unittest class a : """simple docstring""" def __init__( self , lowerCAmelCase_ ) -> List[str]: _A = data # Initialize hash values _A = [ 0x6a_09e_667, 0xb...
720
import json import os from typing import Dict, List, 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 = { 'vocab_file': 'vocab.jso...
83
0
'''simple docstring''' def lowercase__ ( __lowercase : Union[str, Any] ) -> list[list[int]]: """simple docstring""" __UpperCamelCase = [] if len(A__ ) == 1: return [nums.copy()] for _ in range(len(A__ ) ): __UpperCamelCase = ...
399
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.training.common_util...
302
0
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def UpperCAmelCase__ ( lowercase__ , lowercase__ , lowercase__ = "x" , lowercase__ = 10**-10 , lowercase__ = 1 , ) -> complex: __lowercase...
701
import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers c...
634
0
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers....
35
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer __SCREAMING_SNAKE_CASE : int = logging....
661
0
from __future__ import annotations from fractions import Fraction def _lowerCamelCase ( _a , _a ): """simple docstring""" return ( num != den and num % 1_0 == den // 1_0 and (num // 1_0) / (den % 1_0) == num / den ) def _lowerCamelCase ( _a ): """simple docstri...
704
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.modeling_fla...
297
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 = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPT...
358
"""simple docstring""" import argparse import os import re lowerCamelCase_ = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict lowerCamelCase_ = re.compile(r...
498
0
'''simple docstring''' print((lambda quine: quine % quine)("""print((lambda quine: quine %% quine)(%r))"""))
179
'''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
1
def a(lowercase__ , lowercase__ , lowercase__ ): '''simple docstring''' if len(lowercase__ ) != len(lowercase__ ): raise ValueError('The length of profit and weight must be same.' ) if max_weight <= 0: raise ValueError('max_weight must greater than zero.' ) i...
187
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 ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalDetrForSegmen...
604
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_processor import VaeIma...
439
"""simple docstring""" from typing import List, Union import numpy as np 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 PIL import Image from ..image_utils i...
439
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...
318
# 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...
318
1
import os import re import shutil import sys import tempfile import unittest import black __SCREAMING_SNAKE_CASE =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_copies # noqa: E402 ...
718
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffu...
89
0
def __UpperCAmelCase ( __a : list[int] ,__a : list[int] ) -> None: """simple docstring""" _a : List[Any] = len(__a ) print('''The following activities are selected:''' ) # The first activity is always selected _a :...
14
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slo...
428
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor lowercase__ : Dict = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE_ ): """simple docstring""" def __in...
451
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 from ..auto import CONFIG_MAPPING lowercase__ : Tuple = logging.get_logger(__name__) lo...
451
1
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A : Optional[Any] = { """facebook/mask2former-swin-small-coco-instance""": ( """https://huggingface.co/facebook/mask2former...
140
import os from math import logaa def A_ ( A__ = "base_exp.txt" ) -> int: a__ : float = 0 a__ : Optional[Any] = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(A__ ) , A__ ) ) ): ...
302
0
def UpperCAmelCase__( __UpperCAmelCase : int = 1 , __UpperCAmelCase : int = 10_00 ): __snake_case : List[Any] = 1 __snake_case : Any = 0 for divide_by_number in range(__UpperCAmelCase , digit + 1 ): __snake_case : list[int] ...
715
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import pyarrow as pa imp...
679
0
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowerCamelCase__ : Tuple = """\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, autho...
12
# 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...
12
1
import datasets from .evaluate import evaluate _A = "\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n year={2016}\n}\n" _A ...
715
"""simple docstring""" from collections.abc import Sequence from queue import Queue class __UpperCAmelCase : """simple docstring""" def __init__( self : int , A_ : Dict , A_ : List[str] , A_ : Optional[int] , A_ : Any=None , A_ : List[Any]=None...
228
0
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil UpperCAmelCase__ = 1_0_0 UpperCAmelCase__ = set(range(3, NUM_PRIMES, 2)) primes.add(2) UpperCAmelCase__ = 42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not...
186
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_a...
186
1
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar A_ :Optional[Any] = TypeVar('''T''') A_ :Optional[Any] = TypeVar('''U''') class __A ( Generic[T, U] ): """simple docstring""" ...
701
# 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...
154
0
"""simple docstring""" import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup __UpperCAmelCase = { '''User-Agent''': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36''' ''' (KHTML, like Gecko) Chrome/70.0.3538.102 Safari...
642
"""simple docstring""" import os def lowercase__ ( ) -> Optional[Any]: '''simple docstring''' with open(os.path.dirname(lowerCAmelCase__ ) + "/p022_names.txt" ) as file: a__ : Optional[int] = str(file.readlines()[0] ) a__ : Optional[int] = names.repla...
642
1
'''simple docstring''' # Copyright 2022 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 # # ...
27
'''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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageP...
27
1
from __future__ import annotations def lowerCamelCase ( UpperCamelCase : list[int] , UpperCamelCase : list[int] , UpperCamelCase : int ) -> tuple[float, list[float]]: _lowerCamelCase = list(range(len(UpperCamelCase ) ) ) _lowerCame...
544
def lowerCamelCase ( UpperCamelCase : int , UpperCamelCase : int ) -> float: return base * power(UpperCamelCase , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recursion...') A = ...
544
1
import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import from_bytes, ...
661
import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from transformers.utils imp...
661
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : List[str] = logging.get_logger(__name__) _UpperCamelCase : Optional[int] = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bi...
541
'''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_to...
541
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor __a: Optional[int] = logging.get_logger(__name__) class UpperCAmelCase ( a__ ): '''simple docstring''' def __init__( self , ...
428
'''simple docstring''' import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class UpperCAmelCase ( a__ , unittest.Test...
428
1
"""simple docstring""" from __future__ import annotations def lowercase ( UpperCamelCase : str , UpperCamelCase : str ): """simple docstring""" A__ : Any =get_failure_array(UpperCamelCase ) # 2) Step through text searching for pattern A__ ...
656
"""simple docstring""" __A : Union[str, Any] = {str(digit): digit**5 for digit in range(10)} def lowercase ( UpperCamelCase : int ): """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(UpperCamelCase ) ) def lowercase ( ): ...
656
1
import math def lowerCAmelCase ( _lowerCAmelCase : int ): """simple docstring""" UpperCAmelCase__ = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(_lowerCAmelCase ) def lowerCAmelCase ( _lowerCAmelCase : float = 1...
704
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 ( AutoConfig, ...
364
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Union[str, Any] =...
244
'''simple docstring''' from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
244
1
'''simple docstring''' 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 snake_case__ ( a , a , a ) -...
717
'''simple docstring''' from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import T...
566
0
def _lowercase ( __UpperCamelCase : int , __UpperCamelCase : int ): return int((input_a, input_a).count(1 ) != 0 ) def _lowercase ( ): assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate(1 , 0 ) == 1 ...
214
lowerCAmelCase : Dict = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def _lowercase ...
214
1
'''simple docstring''' import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig...
706
'''simple docstring''' import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets __lowerCamelCase : str = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", ...
656
0