code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
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 ( CONF...
366
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'junnyu/roformer_chinese_...
625
0
"""simple docstring""" import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.nu...
650
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ......
625
0
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundfile_availble, is...
317
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'naver-clova-ix/donut-base': 'https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json', # See all Don...
625
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ = { "configuration_groupvit": [ "GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GroupViTConfig", ...
539
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_availabl...
625
0
'''simple docstring''' import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class snake_case ( lowercase , unittest.TestCase ): ...
675
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class snake_case_ ( a ): '''simple docstring''' __UpperCamelCase = 'EncodecFeatureExtractor' __UpperCamelCase ...
625
0
def __magic_name__ ( lowercase_ , lowercase_ ) -> Any: '''simple docstring''' if not isinstance(lowercase_ , lowercase_ ): raise ValueError("iterations must be defined as integers" ) if not isinstance(lowercase_ , lowercase_ )...
606
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def _UpperCAmelCase ( A , A=7 ): '''simple docstring''' UpperCAmelCase__ =None if token is not None: UpperCAmelCase__ ...
625
0
from manim import * class __magic_name__ ( _a): def _UpperCAmelCase ( self : int ): UpperCAmelCase = Rectangle(height=0.5 ,width=0.5 ) UpperCAmelCase = Rectangle(height=0.46 ,width=0.46 ).set_stroke(width=0 ) UpperCAmelCase =...
333
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundf...
625
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings SCREAMING_SNAKE_CASE__ = r'''\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control th...
47
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_S...
625
0
import random from .binary_exp_mod import bin_exp_mod def _a ( __lowercase , __lowercase=1000 ) -> Dict: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __UpperCamelCas...
383
import inspect import unittest from transformers import YolosConfig 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 ...
625
0
'''simple docstring''' UpperCamelCase_ = { """Pillow""": """Pillow<10.0.0""", """accelerate""": """accelerate>=0.20.3""", """av""": """av==9.2.0""", """beautifulsoup4""": """beautifulsoup4""", """black""": """black~=23.1""", """codecarbon""": """codecarbon==1.2.0""", ""...
92
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed...
625
0
'''simple docstring''' import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.prep...
404
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers....
625
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar _SCREAMING_SNAKE_CASE = TypeVar("T") _SCREAMING_SNAKE_CASE = TypeVar("U") class __UpperCAmelCase ( Generic[T, U] ): '''simple docstring''' ...
366
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def _UpperCAmelCase ( A , A , A , A=1024 ): '''simple docstring''' UpperCAmelCase__ , UpperCAmelCase__ ...
625
0
"""simple docstring""" from math import factorial def SCREAMING_SNAKE_CASE_ ( snake_case : str = 20 )-> str: _lowerCamelCase = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... _lowerCamelCase = n // 2 ...
650
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from...
625
0
import inspect import unittest from transformers import MobileNetVaConfig 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 ...t...
317
from math import factorial def _UpperCAmelCase ( A = 20 ): '''simple docstring''' UpperCAmelCase__ =2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... UpperCAmelCase__ =n // 2 return int(factorial(A ...
625
0
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_f...
539
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def _UpperCAmelCase ( A ): '''simple docstring''' UpperCAmelCase__ ...
625
0
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device ...
675
from __future__ import annotations import requests UpperCamelCase_ = set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories c...
625
0
import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class __UpperCAmelCase : """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> List[str]: ...
606
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFea...
625
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 ...t...
333
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCamelCase_ = { 'configuration_owlvit':...
625
0
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin ...
47
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTim...
625
0
from __future__ import annotations def _a ( __lowercase ) -> Union[str, Any]: """simple docstring""" if len(__lowercase ) == 0: return [] __UpperCamelCase , __UpperCamelCase = min(__lowercase ), max(__lowercase ) __UpperCame...
383
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_config...
625
0
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require...
92
def _UpperCAmelCase ( A ): '''simple docstring''' for i in range(len(A ) - 1 , 0 , -1 ): UpperCAmelCase__ =False for j in range(A , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: UpperCAme...
625
0
'''simple docstring''' import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ...
404
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'microsoft/wavlm-base': 'https://huggingface.co/microsoft/wavlm-base/resolve/main/confi...
625
0
'''simple docstring''' def lowerCamelCase( SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ) -> Dict: if index == r: for j in range(SCREAMING_SNAKE_CASE_ ): p...
366
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'junnyu/roformer_chinese_...
625
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : Optional[int] ={ """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""], } try: if not is_torch_available(): ...
650
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ......
625
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def UpperCAmelCase__ ( __snake_case ) -> Optional[Any]: _A = prime_factors(__snake_case ) if is_square_free(__snake_case ): return -1 if len(__snake_case ) % 2 else 1 re...
317
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'naver-clova-ix/donut-base': 'https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json', # See all Don...
625
0
'''simple docstring''' import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, Swin...
539
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_availabl...
625
0
'''simple docstring''' from math import sqrt def __snake_case ( UpperCAmelCase_ : Union[str, Any] ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not prim...
675
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class snake_case_ ( a ): '''simple docstring''' __UpperCamelCase = 'EncodecFeatureExtractor' __UpperCamelCase ...
625
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __a : Tuple = { """configuration_mask2former""": [ """MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mask2FormerConfig""", ...
606
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def _UpperCAmelCase ( A , A=7 ): '''simple docstring''' UpperCAmelCase__ =None if token is not None: UpperCAmelCase__ ...
625
0
def __UpperCamelCase ( _lowerCAmelCase ): """simple docstring""" for i in range(len(_lowerCAmelCase ) - 1 , 0 , -1 ): UpperCAmelCase = False for j in range(_lowerCAmelCase , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: ...
333
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundf...
625
0
import argparse import os import re SCREAMING_SNAKE_CASE__ = '''src/transformers/models/auto''' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict SCREAMING_SNAKE_CASE__ = re.compile(r'''[A-Z_...
47
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_S...
625
0
def _a ( __lowercase , __lowercase = False ) -> List[Any]: """simple docstring""" if not isinstance(__lowercase , __lowercase ): __UpperCamelCase = F"""Expected string as input, found {type(__lowercase )}""" raise ValueError(_...
383
import inspect import unittest from transformers import YolosConfig 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 ...
625
0
'''simple docstring''' from __future__ import annotations from cmath import sqrt def _lowerCAmelCase ( __magic_name__ : int , __magic_name__ : str , __magic_name__ : List[Any] ) -> Dict: if a == 0: raise ValueError('''Coefficient \'a\' mus...
92
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed...
625
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __lowerCamelCase : Dict = logging.get_logger(__name__) __lowerCamelCase : Tuple = { 'ut/deta': 'https://huggingface.co/ut/deta/resolve/mai...
404
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers....
625
0
'''simple docstring''' def lowerCamelCase( SCREAMING_SNAKE_CASE_ ) -> int: if not numbers: return 0 if not isinstance(SCREAMING_SNAKE_CASE_ ,(list, tuple) ) or not all( isinstance(SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ) for number in numbers ): ...
366
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def _UpperCAmelCase ( A , A , A , A=1024 ): '''simple docstring''' UpperCAmelCase__ , UpperCAmelCase__ ...
625
0
"""simple docstring""" from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class __a ( lower...
650
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from...
625
0
def UpperCAmelCase__ ( __snake_case = 1_000 ) -> int: _A = 3 _A = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 return result if __name__ == "__main__": print(f'''{solution() = }''')
317
from math import factorial def _UpperCAmelCase ( A = 20 ): '''simple docstring''' UpperCAmelCase__ =2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... UpperCAmelCase__ =n // 2 return int(factorial(A ...
625
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING UpperCAmelCase_ = logging.get_logger(__name__) class __lowercase ( __magic_name__ ): _a = ...
539
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def _UpperCAmelCase ( A ): '''simple docstring''' UpperCAmelCase__ ...
625
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : Any = { """configuration_mobilenet_v2""": [ """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
675
from __future__ import annotations import requests UpperCamelCase_ = set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories c...
625
0
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transforme...
606
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFea...
625
0
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class __magic_name__ : _UpperCAmelCase : Optional[int] = 42 # [batch_size x 3] _UpperCAmelCase : List[str] = 42 # [batch_size x 3] _UpperCAmelCase : List[Any] = 42 # [batch...
333
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCamelCase_ = { 'configuration_owlvit':...
625
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class snake_case ( metaclass=__lowercase ): UpperCAmelCase__ = ['''note_seq'''] def __init__(self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_CASE_ ): """simple docstri...
626
"""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 timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transfo...
626
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( ...
626
"""simple docstring""" import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttentio...
626
1
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
626
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __lowercase ): UpperCAmelCase__ = (UnCLIPScheduler,) def _lowercase (self , **SCREAMING_SNAKE_CASE_ ): ""...
626
1
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = {'vocab_file': 'vocab.json'} lowerCAmelCase__ = { 'voca...
626
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqa...
626
1
"""simple docstring""" # Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - g...
626
"""simple docstring""" from __future__ import annotations import math def _lowerCamelCase ( __a ): if num <= 0: SCREAMING_SNAKE_CASE_ = F'{num}: Invalid input, please enter a positive integer.' raise ValueError(__a ) SCREAMING_SNAKE_CASE_ = [True] * (num + 1) ...
626
1
"""simple docstring""" def _lowerCamelCase ( __a ): if len(__a ) < 2: return collection def circle_sort_util(__a, __a, __a ) -> bool: SCREAMING_SNAKE_CASE_ = False if low == high: return swapped SCREAMING_SNAKE_CASE_ = low SCREAMING_SNA...
626
"""simple docstring""" # 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 # # ...
626
1
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( __a, __a ): if partitions <= 0: raise ValueError('''partitions must be a positive number!''' ) if partitions > number_of_bytes: raise ValueError('''partitions can not > number_of_bytes!''' ) S...
626
"""simple docstring""" from ..utils import DummyObject, requires_backends class snake_case ( metaclass=__lowercase ): UpperCAmelCase__ = ['''note_seq'''] def __init__(self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_CASE_ ): """simple docstri...
626
1
"""simple docstring""" class snake_case ( __lowercase ): pass class snake_case ( __lowercase ): pass class snake_case : def __init__(self ): """simple docstring""" SCREAMING_SNAKE_CASE_ = [ [], [],...
626
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfor...
626
1
"""simple docstring""" def _lowerCamelCase ( __a ): return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
626
"""simple docstring""" def _lowerCamelCase ( __a ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE_ = 1 SCREAMING_SNAKE_CASE_ = 1 while repunit: SCREAMING_SNAKE_CASE_ = (10 * repunit + 1) % divisor repunit_index += 1 return repuni...
626
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase__ = {'configuration_vit': ['VIT_PRETRAINED_CONFIG_ARCHIVE_MAP',...
626
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( __a, __a = None ): SCREAMING_SNAKE_CASE_ = word_bank or [] # create a table SCREAMING_SNAKE_CASE_ = len(__a ) + 1 SCREAMING_SNAKE_CASE_ = [] for _ in range(__a ): tabl...
626
1
"""simple docstring""" import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run ...
626
"""simple docstring""" import datasets from .evaluate import evaluate lowerCAmelCase__ = '\\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={EMNL...
626
1
"""simple docstring""" def _lowerCamelCase ( __a ): return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], }, { 0: [6],...
626
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def _lowerCamelCase ( __a, __a, __a, __a = 100, ): SCREAMING_SNAKE_CASE_ = x_start SCREAMING_SNAKE_CASE_ = fnc(__a ) SCREAMING_SNAKE_CASE_ = 0.0 for _ in ran...
626
1
"""simple docstring""" def _lowerCamelCase ( __a, __a ): SCREAMING_SNAKE_CASE_ = '''''' for i in table: res += inp[i - 1] return res def _lowerCamelCase ( __a ): return data[1:] + data[0] def _lowerCamelCase ( __a, __a ): SCREAMING_SNAK...
626
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision...
626
1
"""simple docstring""" import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version lowerCAmelCase__ = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): from nltk import word_tokenize ...
626
"""simple docstring""" from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _lowerCamelCase ( __a = "isbn/0140328726" ): SCREAMING_SNAKE_CASE_ = olid.strip().strip('''/''' ) # Remove leading/trailing whitespace & slashes if n...
626
1
"""simple docstring""" import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def _lowerCamelCase ( __a )...
626
"""simple docstring""" import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.di...
626
1
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def _lowerCamelCase ( __a, __a, __a, __a = 100, ): SCREAMING_SNAKE_CASE_ = x_start SCREAMING_SNAKE_CASE_ = fnc(__a ) SCREAMING_SNAKE_CASE_ = 0.0 for _ in ran...
626
"""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 snake_case ( __lowercase , ...
626
1
"""simple docstring""" from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer lowerCAmelCase__ = logging.get_logger(__na...
626
"""simple docstring""" import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='%(message)s') def _lowerCamelCase ( __a ): return input_array.reshape((input_array.size, 1) ) def _lowerCamelCase ( __a, __...
626
1
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __lowercase ): UpperCAmelCase__ = (UnCLIPScheduler,) def _lowercase (self , **SCREAMING_SNAKE_CASE_ ): ""...
626
"""simple docstring""" import doctest from collections import deque import numpy as np class snake_case : def __init__(self ): """simple docstring""" SCREAMING_SNAKE_CASE_ = [2, 1, 2, -1] SCREAMING_SNAKE_CASE_ = [1, 2, 3, 4] def...
626
1
"""simple docstring""" import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _lowerCamelCase ...
626
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import pat...
626
1
"""simple docstring""" from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available()...
626
"""simple docstring""" from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
626
1
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from...
626
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings lowerCAmelCase__ = r'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the m...
626
1
"""simple docstring""" import inspect import unittest class snake_case ( unittest.TestCase ): def _lowercase (self ): """simple docstring""" try: import diffusers # noqa: F401 except ImportError: assert False def ...
626
"""simple docstring""" from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ...
626
1
"""simple docstring""" # 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 # # ...
626
"""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 timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transfo...
626
1
"""simple docstring""" import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeli...
626
"""simple docstring""" import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttentio...
626
1
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def _lowerCamelCase ( __a ): # encoder.embeddings are double copied in origina...
626
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __lowercase ): UpperCAmelCase__ = (UnCLIPScheduler,) def _lowercase (self , **SCREAMING_SNAKE_CASE_ ): ""...
626
1
"""simple docstring""" import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeach...
626
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqa...
626
1
"""simple docstring""" import argparse import json import subprocess def _lowerCamelCase ( __a, __a ): SCREAMING_SNAKE_CASE_ = [] SCREAMING_SNAKE_CASE_ = ( F'curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer {token}"' ''' https://api.githu...
626
"""simple docstring""" from __future__ import annotations import math def _lowerCamelCase ( __a ): if num <= 0: SCREAMING_SNAKE_CASE_ = F'{num}: Invalid input, please enter a positive integer.' raise ValueError(__a ) SCREAMING_SNAKE_CASE_ = [True] * (num + 1) ...
626
1
"""simple docstring""" 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 ...
626
"""simple docstring""" # 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 # # ...
626
1
"""simple docstring""" import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments lowerCAmelCase__ = logging.getLogger(__name__) @dataclass class snake_case ( __lowercase ): ...
626
"""simple docstring""" from ..utils import DummyObject, requires_backends class snake_case ( metaclass=__lowercase ): UpperCAmelCase__ = ['''note_seq'''] def __init__(self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_CASE_ ): """simple docstri...
626
1
"""simple docstring""" def _lowerCamelCase ( ): SCREAMING_SNAKE_CASE_ = [] SCREAMING_SNAKE_CASE_ = 1 while len(__a ) < 1E6: constant.append(str(__a ) ) i += 1 SCREAMING_SNAKE_CASE_ = ''''''.join(__a ) return ( int(constant[0] ) ...
626
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfor...
626
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 ( AutoConfig, A...
626
"""simple docstring""" def _lowerCamelCase ( __a ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE_ = 1 SCREAMING_SNAKE_CASE_ = 1 while repunit: SCREAMING_SNAKE_CASE_ = (10 * repunit + 1) % divisor repunit_index += 1 return repuni...
626
1
"""simple docstring""" import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem lowerCAmelCase__ = importlib.util.find_spec('s3fs') is not None if _has_safs: from .safi...
626
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( __a, __a = None ): SCREAMING_SNAKE_CASE_ = word_bank or [] # create a table SCREAMING_SNAKE_CASE_ = len(__a ) + 1 SCREAMING_SNAKE_CASE_ = [] for _ in range(__a ): tabl...
626
1
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTester...
626
"""simple docstring""" import datasets from .evaluate import evaluate lowerCAmelCase__ = '\\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={EMNL...
626
1
"""simple docstring""" import datasets from .evaluate import evaluate lowerCAmelCase__ = '\\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={EMNL...
626
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def _lowerCamelCase ( __a, __a, __a, __a = 100, ): SCREAMING_SNAKE_CASE_ = x_start SCREAMING_SNAKE_CASE_ = fnc(__a ) SCREAMING_SNAKE_CASE_ = 0.0 for _ in ran...
626
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', 'XCLIPVi...
626
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision...
626
1
"""simple docstring""" import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert ...
626
"""simple docstring""" from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _lowerCamelCase ( __a = "isbn/0140328726" ): SCREAMING_SNAKE_CASE_ = olid.strip().strip('''/''' ) # Remove leading/trailing whitespace & slashes if n...
626
1
"""simple docstring""" class snake_case : def __init__(self ): """simple docstring""" SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ = {} def _lowercase (self , SCREAMING_SNAKE_C...
626
"""simple docstring""" import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.di...
626
1
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline...
626
"""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 snake_case ( __lowercase , ...
626
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', '...
626
"""simple docstring""" import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='%(message)s') def _lowerCamelCase ( __a ): return input_array.reshape((input_array.size, 1) ) def _lowerCamelCase ( __a, __...
626
1
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def _lowerCamelCase ( __a ): return np.dot(__a, __a ) class snake_case : def __init__(self , *, SCREAMING_SNAKE_CASE_ ...
626
"""simple docstring""" import doctest from collections import deque import numpy as np class snake_case : def __init__(self ): """simple docstring""" SCREAMING_SNAKE_CASE_ = [2, 1, 2, -1] SCREAMING_SNAKE_CASE_ = [1, 2, 3, 4] def...
626
1
"""simple docstring""" import os import time import numpy as np import onnxruntime as ort lowerCAmelCase__ = '1' lowerCAmelCase__ = '0' lowerCAmelCase__ = '1' lowerCAmelCase__ = ort.SessionOptions() lowerCAmelCase__ = ort.GraphOptimizationLevel.ORT_DISABLE_ALL print('Create i...
626
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import pat...
626
1
"""simple docstring""" import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda...
626
"""simple docstring""" from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
626
1
"""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 snake_case ( __lowercase , ...
626
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings lowerCAmelCase__ = r'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the m...
626
1
"""simple docstring""" from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin ...
626
"""simple docstring""" from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ...
626
1
"""simple docstring""" import collections import importlib.util import os import re from pathlib import Path lowerCAmelCase__ = 'src/transformers' # Matches is_xxx_available() lowerCAmelCase__ = re.compile(r'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} lowerCAmelCase__ ...
626
"""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 timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transfo...
626
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
626
"""simple docstring""" import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttentio...
626
1
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def _lowerCamelCase ( __a ): return ConvertCommand( args.model_type, args.tf_checkpoint, args.pytorch_dump_output, args.config, args.fine...
626
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __lowercase ): UpperCAmelCase__ = (UnCLIPScheduler,) def _lowercase (self , **SCREAMING_SNAKE_CASE_ ): ""...
626
1
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def _lowerCamelCase ( __a ): SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ = analyze_text(__a ) SCREAMING_SNAKE_CASE_ = list(''' ''' +...
626
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqa...
626
1
"""simple docstring""" import argparse 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 ...
626
"""simple docstring""" from __future__ import annotations import math def _lowerCamelCase ( __a ): if num <= 0: SCREAMING_SNAKE_CASE_ = F'{num}: Invalid input, please enter a positive integer.' raise ValueError(__a ) SCREAMING_SNAKE_CASE_ = [True] * (num + 1) ...
626
1
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( __a, __a, __a, __a ): # noqa: E741 while r - l > 1: SCREAMING_SNAKE_CASE_ = (l + r) // 2 if v[m] >= key: SCREAMING_SNAKE_CASE_ = m else: SCREAMING_SNAKE_CASE_ ...
626
"""simple docstring""" # 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 # # ...
626
1
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowerCAmelCase__ = input('Enter image url: ').strip() print(f'''Downloading image from {url} ...''') lowerCAmelCase__ = BeautifulSoup(requests.get(url).con...
626
"""simple docstring""" from ..utils import DummyObject, requires_backends class snake_case ( metaclass=__lowercase ): UpperCAmelCase__ = ['''note_seq'''] def __init__(self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_CASE_ ): """simple docstri...
626
1
"""simple docstring""" def _lowerCamelCase ( __a ): SCREAMING_SNAKE_CASE_ = 1 SCREAMING_SNAKE_CASE_ = 2 while i * i <= n: SCREAMING_SNAKE_CASE_ = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: ...
626
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfor...
626
1
"""simple docstring""" import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.di...
626
"""simple docstring""" def _lowerCamelCase ( __a ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE_ = 1 SCREAMING_SNAKE_CASE_ = 1 while repunit: SCREAMING_SNAKE_CASE_ = (10 * repunit + 1) % divisor repunit_index += 1 return repuni...
626
1
"""simple docstring""" def _lowerCamelCase ( __a ): if len(__a ) <= 1: return lst SCREAMING_SNAKE_CASE_ = 1 while i < len(__a ): if lst[i - 1] <= lst[i]: i += 1 else: SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ = lst[i], lst[i - 1] i -...
626
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( __a, __a = None ): SCREAMING_SNAKE_CASE_ = word_bank or [] # create a table SCREAMING_SNAKE_CASE_ = len(__a ) + 1 SCREAMING_SNAKE_CASE_ = [] for _ in range(__a ): tabl...
626
1
"""simple docstring""" import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if v...
626
"""simple docstring""" import datasets from .evaluate import evaluate lowerCAmelCase__ = '\\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={EMNL...
626
1
"""simple docstring""" from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowerCAmelCase__ = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that gene...
626
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def _lowerCamelCase ( __a, __a, __a, __a = 100, ): SCREAMING_SNAKE_CASE_ = x_start SCREAMING_SNAKE_CASE_ = fnc(__a ) SCREAMING_SNAKE_CASE_ = 0.0 for _ in ran...
626
1
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( __a, __a, __a, __a, __a, ): SCREAMING_SNAKE_CASE_ = len(__a ) # If row is equal to the size of the board it means there are a queen in each row in # the current board (possible_board) i...
626
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision...
626
1
"""simple docstring""" 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, BartForSequence...
626
"""simple docstring""" from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _lowerCamelCase ( __a = "isbn/0140328726" ): SCREAMING_SNAKE_CASE_ = olid.strip().strip('''/''' ) # Remove leading/trailing whitespace & slashes if n...
626
1
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast lowerCAmelCase__ = datasets.utils.logging.get_logger(__name__) @dataclass class snak...
626
"""simple docstring""" import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.di...
626
1
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require...
626
"""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 snake_case ( __lowercase , ...
626
1