code stringlengths 86 54.5k | code_codestyle int64 0 371 | style_context stringlengths 87 49.2k | style_context_codestyle int64 0 349 | label int64 0 1 |
|---|---|---|---|---|
'''simple docstring'''
import logging
import math
import os
from dataclasses import dataclass, field
from glob import glob
from typing import Optional
from torch.utils.data import ConcatDataset
import transformers
from transformers import (
CONFIG_MAPPING,
MODEL_WITH_LM_HEAD_MAPPING,
AutoConfig,
... | 363 |
'''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
#
... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
return number & 1 == 0
if __name__ == "__main__":
import doctest
doctest.testmod()
| 364 |
'''simple docstring'''
import argparse
import requests
import torch
from PIL import Image
from torchvision.transforms import Compose, Normalize, Resize, ToTensor
from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor
def __UpperCamelCase ( _UpperCAmelCase ):
... | 37 | 0 |
'''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__ : str = importlib.util.find_spec("s3fs") is not None
if _has_safs:
... | 365 |
'''simple docstring'''
import gc
import math
import unittest
import torch
from diffusers import UNetaDModel
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism
from .test_modeling_common import ModelTesterMix... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : Optional[int] = len(_UpperCAmelCase )
print("The following activities are selected:" )
# The first activity is always selected
__UpperCAmelCase : List[Any... | 366 |
'''simple docstring'''
import warnings
from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor
lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__)
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase = 4000000 ):
__UpperCAmelCase : str = []
__UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = 0, 1
while b <= n:
if b % 2 == 0:
even_fibs.append(snake_case_ )
__UpperCAm... | 367 |
'''simple docstring'''
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
... | 37 | 0 |
'''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,
EfficientFormerForImageClassificationWithTea... | 368 |
'''simple docstring'''
import argparse
import re
from flax.traverse_util import flatten_dict, unflatten_dict
from tax import checkpoints
from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration
from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc... | 37 | 0 |
'''simple docstring'''
import copy
import os
from typing import TYPE_CHECKING, List, Union
if TYPE_CHECKING:
pass
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : Dict = logging.get_logger(__name__)
lowerCAmelCase__ : Dict = {
... | 369 |
'''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... | 37 | 0 |
'''simple docstring'''
from typing import Dict, List, Optional, Tuple, Union
import numpy as np
from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
center_crop,
get_resize_output_image_size,
normalize,
rescale,
resize,
... | 370 |
'''simple docstring'''
from __future__ import annotations
import math
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
if depth < 0:
raise ValueError("Depth cannot be less than 0" )
if not scores:
raise ValueErro... | 37 | 0 |
'''simple docstring'''
from ..utils import DummyObject, requires_backends
class SCREAMING_SNAKE_CASE__ ( metaclass=_SCREAMING_SNAKE_CASE ):
"""simple docstring"""
SCREAMING_SNAKE_CASE = ["torch", "scipy"]
def __init__( self : Dict , *UpperCAmelCa... | 371 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : Dict = logging.get_logger(__name__)
lowerCAmelCase__ : int = {
"google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json",
"g... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase ):
if not nums:
raise ValueError("List is empty" )
return sum(_UpperCAmelCase ) / len(_UpperCAmelCase )
if __name__ == "__main__":
import doctest
doct... | 350 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
try:
__UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase )
except ValueError:
raise ValueError("Please enter a valid number" )
__UpperCAmelCase : str = decimal - int(_U... | 37 | 0 |
'''simple docstring'''
import os
import unittest
from transformers import BatchEncoding
from transformers.models.bert.tokenization_bert import (
BasicTokenizer,
WordpieceTokenizer,
_is_control,
_is_punctuation,
_is_whitespace,
)
from transformers.models.prophetnet.tokenization_prophetnet imp... | 351 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
if p < 2:
raise ValueError("p should not be less than 2!" )
elif p == 2:
return True
__UpperCAmelCase : List[str] = 4
__UpperCAmelCase : int = (1 << p) - 1
for _ in range(p - ... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
import math
from collections import Counter
from string import ascii_lowercase
def __UpperCamelCase ( _UpperCAmelCase ):
__UpperCAmelCase : str = analyze_text(_UpperCAmelCase )
__UpperCAmelCase : Union[str, Any]... | 352 |
'''simple docstring'''
from collections.abc import Callable
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : float = a
__UpperCAmelCase : float = b
if function(_UpperCAmelCase ) == 0: # one of the a or... | 37 | 0 |
'''simple docstring'''
import argparse
import os
from . import (
ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
BART_PRETRAINED_MODEL_ARCHIVE_LIST,
BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP,
DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
... | 353 |
'''simple docstring'''
import unittest
from transformers import PegasusTokenizer, PegasusTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow
from transformers.utils import cached_property
from ...test_tokenization_common import Toke... | 37 | 0 |
'''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 transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel
from transformers... | 354 |
'''simple docstring'''
from __future__ import annotations
import collections
import pprint
from pathlib import Path
def __UpperCamelCase ( _UpperCAmelCase ):
return "".join(sorted(_UpperCAmelCase ) )
def __UpperCamelCase ( _UpperCAmelCase ):
return word_by_signature[signatu... | 37 | 0 |
from collections.abc import Callable
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : float = a
__UpperCAmelCase : float = b
if function(_UpperCAmelCase ) == 0: # one of the a or b is a root for the fun... | 355 |
'''simple docstring'''
import collections
import inspect
import unittest
from transformers import SwinvaConfig
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_configurat... | 37 | 0 |
'''simple docstring'''
import argparse
from collections import OrderedDict
from pathlib import Path
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from torchvision.transforms import functional as F
from transformers import DetrImageProcessor, TableTransformerConfig, TableTransf... | 356 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase ):
if not nums:
raise ValueError("List is empty" )
return sum(_UpperCAmelCase ) / len(_UpperCAmelCase )
if __name__ == "__main__":
import doctest
doctest.testmod()
| 37 | 0 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ):
if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1:
raise ValueError("You cannot supply more or less than 2 values" )
elif electron_conc ... | 357 |
'''simple docstring'''
#
# This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or
# many nodes) can talk to each other via nccl and allocate gpu memory.
#
# To run first adjust the number of processes and nodes:
#
# python -m torch.distributed.run --nproc_per_node 2 --nnod... | 37 | 0 |
'''simple docstring'''
import argparse
import json
from pathlib import Path
import requests
import torch
from huggingface_hub import cached_download, hf_hub_download, hf_hub_url
from PIL import Image
from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig
from transformers.u... | 358 |
'''simple docstring'''
import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
SCREAMING_SNAKE_CASE = '''M-CLIP'''
def __init__( self : List[str] ,... | 37 | 0 |
'''simple docstring'''
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 SCREAMING_SNAKE_CASE__ ( sn... | 359 |
'''simple docstring'''
import math
class SCREAMING_SNAKE_CASE__ :
"""simple docstring"""
def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1
"""simple docstring"""
__UpperCAmelCase :... | 37 | 0 |
'''simple docstring'''
from typing import Any
class SCREAMING_SNAKE_CASE__ :
"""simple docstring"""
def __init__( self : Any , UpperCAmelCase_ : Any ):
"""simple docstring"""
__UpperCAmelCase : str = data
__Up... | 360 |
'''simple docstring'''
from datetime import datetime as dt
import os
from github import Github
lowerCAmelCase__ : Union[str, Any] = [
"good first issue",
"good second issue",
"good difficult issue",
"feature request",
"new model",
"wip",
]
def __UpperCamelCase ( ):
... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase = 4000000 ):
__UpperCAmelCase : Dict = []
__UpperCAmelCase : List[str] = 0, 1
while b <= n:
if b % 2 == 0:
even_fibs.append(_UpperCAmelCase )
__UpperCAmelCase : Optional[A... | 361 |
'''simple docstring'''
from heapq import heappop, heappush
import numpy as np
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ):
__UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape
__UpperCAmelCase : List[... | 37 | 0 |
import math
import os
import re
import sys
import unittest
from pathlib import Path
from typing import Tuple
from unittest.mock import patch
from parameterized import parameterized
from transformers.testing_utils import (
CaptureStderr,
ExtendSysPath,
TestCasePlus,
execute_subprocess_async,
... | 362 |
'''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_ber... | 37 | 0 |
'''simple docstring'''
import argparse
import requests
import torch
from PIL import Image
from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor
def __UpperCamelCase ( _UpperCAmelCase ):
if "cls_token" in name:
__UpperCAmelCase : Tuple = name.repla... | 363 |
'''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
#
... | 37 | 0 |
'''simple docstring'''
import json
import os
import re
import sys
import urllib.request
import requests
from bsa import BeautifulSoup
lowerCAmelCase__ : Optional[int] = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
" (KHTML, like Gecko) Chrome/70.0.3538.102... | 364 |
'''simple docstring'''
import argparse
import requests
import torch
from PIL import Image
from torchvision.transforms import Compose, Normalize, Resize, ToTensor
from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor
def __UpperCamelCase ( _UpperCAmelCase ):
... | 37 | 0 |
'''simple docstring'''
from scipy.stats import pearsonr
import datasets
lowerCAmelCase__ : List[Any] = "\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-v... | 365 |
'''simple docstring'''
import gc
import math
import unittest
import torch
from diffusers import UNetaDModel
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism
from .test_modeling_common import ModelTesterMix... | 37 | 0 |
'''simple docstring'''
import copy
import os
from typing import Union
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : str = logging.get_logger(__name__)
lowerCAmelCase__ : Union[str, Any] = {
"google/pix2struct-textcaps-base": ... | 366 |
'''simple docstring'''
import warnings
from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor
lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__)
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase = "The quick brown fox jumps over the lazy dog", ):
__UpperCAmelCase : List[Any] = set()
# Replace all the whitespace in our sentence
__UpperCAmelCase : int = input_str.replace(" ", "" )
for ... | 367 |
'''simple docstring'''
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ):
if b == 0:
return (1, 0)
(__UpperCAmelCase) : Optional[int] = extended_euclid(_UpperCAmelCase, a % b )
__UpperCAmelCase : int = ... | 368 |
'''simple docstring'''
import argparse
import re
from flax.traverse_util import flatten_dict, unflatten_dict
from tax import checkpoints
from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration
from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc... | 37 | 0 |
'''simple docstring'''
import argparse
import json
import torch
from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase=1 ):
if n_shave_prefix_segments >= 0:
return ".".join(path.split("." )[n_shave_prefix_segments:... | 369 |
'''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... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase = 1000 ):
__UpperCAmelCase : Optional[Any] = 1, 1
__UpperCAmelCase : Any = []
for i in range(1, n + 1 ):
__UpperCAmelCase : Union[str, Any] = prev_numerator + 2 * prev... | 370 |
'''simple docstring'''
from __future__ import annotations
import math
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
if depth < 0:
raise ValueError("Depth cannot be less than 0" )
if not scores:
raise ValueErro... | 37 | 0 |
'''simple docstring'''
from .imports import is_rich_available
if is_rich_available():
from rich.traceback import install
install(show_locals=False)
else:
raise ModuleNotFoundError("To use the rich extension, install rich with `pip install rich`")
| 371 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : Dict = logging.get_logger(__name__)
lowerCAmelCase__ : int = {
"google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json",
"g... | 37 | 0 |
'''simple docstring'''
from math import pow
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ):
if current_sum == needed_sum:
# If the sum of the powers is equal to needed_sum, then we have a solution.
solutions_cou... | 350 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
try:
__UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase )
except ValueError:
raise ValueError("Please enter a valid number" )
__UpperCAmelCase : str = decimal - int(_U... | 37 | 0 |
'''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__ : Optional[Any] = logging.getLogger(__name__)
@dataclass
class SCREAMING... | 351 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
if p < 2:
raise ValueError("p should not be less than 2!" )
elif p == 2:
return True
__UpperCAmelCase : List[str] = 4
__UpperCAmelCase : int = (1 << p) - 1
for _ in range(p - ... | 37 | 0 |
'''simple docstring'''
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
lowerCAmelCase__ : Dict = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]}
try:
if not is_vision_available(... | 352 |
'''simple docstring'''
from collections.abc import Callable
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : float = a
__UpperCAmelCase : float = b
if function(_UpperCAmelCase ) == 0: # one of the a or... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : Union[str, Any] = 0
while b > 0:
if b & 1:
res += a
a += a
b >>= 1
return res
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCas... | 353 |
'''simple docstring'''
import unittest
from transformers import PegasusTokenizer, PegasusTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow
from transformers.utils import cached_property
from ...test_tokenization_common import Toke... | 37 | 0 |
'''simple docstring'''
import inspect
import os
import unittest
import torch
import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
execute_subprocess_async,
require_cpu,
require_huggingface_suite,
require_multi_gpu,
require_single_gpu,
)
from accelerate... | 354 |
'''simple docstring'''
from __future__ import annotations
import collections
import pprint
from pathlib import Path
def __UpperCamelCase ( _UpperCAmelCase ):
return "".join(sorted(_UpperCAmelCase ) )
def __UpperCamelCase ( _UpperCAmelCase ):
return word_by_signature[signatu... | 37 | 0 |
import warnings
from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor
lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__)
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
def __init__( sel... | 355 |
'''simple docstring'''
import collections
import inspect
import unittest
from transformers import SwinvaConfig
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_configurat... | 37 | 0 |
'''simple docstring'''
from typing import Callable, List, Optional, Tuple, Union
import torch
from transformers import CLIPTextModel, CLIPTokenizer
from ...configuration_utils import ConfigMixin, register_to_config
from ...models import ModelMixin, TransformeraDModel, VQModel
from ...schedulers import VQDiffu... | 356 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase ):
if not nums:
raise ValueError("List is empty" )
return sum(_UpperCAmelCase ) / len(_UpperCAmelCase )
if __name__ == "__main__":
import doctest
doctest.testmod()
| 37 | 0 |
'''simple docstring'''
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union
lowerCAmelCase__ : Any = re.compile(R"^(?P<major>\d+)" R"\.(?P<minor>\d+)" R"\.(?P<patch>\d+)$")
@total_ordering
@dataclass
class SC... | 357 |
'''simple docstring'''
#
# This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or
# many nodes) can talk to each other via nccl and allocate gpu memory.
#
# To run first adjust the number of processes and nodes:
#
# python -m torch.distributed.run --nproc_per_node 2 --nnod... | 37 | 0 |
'''simple docstring'''
import unittest
from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow
if is_torch_available():
import torch
from transformers import XLMRobertaModel
@require_sentencepiece
@require_token... | 358 |
'''simple docstring'''
import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
SCREAMING_SNAKE_CASE = '''M-CLIP'''
def __init__( self : List[str] ,... | 37 | 0 |
'''simple docstring'''
from manim import *
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
def lowerCamelCase_ ( self : Any ):
"""simple docstring"""
__UpperCAmelCase : str = Rectangle(heigh... | 359 |
'''simple docstring'''
import math
class SCREAMING_SNAKE_CASE__ :
"""simple docstring"""
def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1
"""simple docstring"""
__UpperCAmelCase :... | 37 | 0 |
'''simple docstring'''
import json
import os
from typing import Optional, Tuple
import regex as re
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__)
lowerCAmelCase__ : Dict = {
"vocab_f... | 360 |
'''simple docstring'''
from datetime import datetime as dt
import os
from github import Github
lowerCAmelCase__ : Union[str, Any] = [
"good first issue",
"good second issue",
"good difficult issue",
"feature request",
"new model",
"wip",
]
def __UpperCamelCase ( ):
... | 37 | 0 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : Dict = logging.get_logger(__name__)
lowerCAmelCase__ : int = {
"google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json",
"g... | 361 |
'''simple docstring'''
from heapq import heappop, heappush
import numpy as np
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ):
__UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape
__UpperCAmelCase : List[... | 37 | 0 |
import gzip
import hashlib
import json
import multiprocessing
import os
import re
import shutil
import time
from pathlib import Path
import numpy as np
from arguments import PreprocessingArguments
from datasets import load_dataset
from minhash_deduplication import deduplicate_dataset
from transformers import Au... | 362 |
'''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_ber... | 37 | 0 |
'''simple docstring'''
import random
import unittest
import numpy as np
import torch
from diffusers import (
DPMSolverMultistepScheduler,
EulerAncestralDiscreteScheduler,
EulerDiscreteScheduler,
LMSDiscreteScheduler,
OnnxStableDiffusionUpscalePipeline,
PNDMScheduler,
)
from diffusers.ut... | 363 |
'''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
#
... | 37 | 0 |
'''simple docstring'''
from statistics import mean
import numpy as np
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : int = 0
# Number of processes finished
__UpperCAmelCase : Any = 0
#... | 364 |
'''simple docstring'''
import argparse
import requests
import torch
from PIL import Image
from torchvision.transforms import Compose, Normalize, Resize, ToTensor
from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor
def __UpperCamelCase ( _UpperCAmelCase ):
... | 37 | 0 |
'''simple docstring'''
import inspect
import tempfile
from collections import OrderedDict, UserDict
from collections.abc import MutableMapping
from contextlib import ExitStack, contextmanager
from dataclasses import fields
from enum import Enum
from typing import Any, ContextManager, List, Tuple
import numpy as... | 365 |
'''simple docstring'''
import gc
import math
import unittest
import torch
from diffusers import UNetaDModel
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism
from .test_modeling_common import ModelTesterMix... | 37 | 0 |
'''simple docstring'''
from collections import OrderedDict
from typing import Mapping
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
lowerCAmelCase__ : str = logging.get_logger(__name__)
lowerCAmelCase__ : List[Any] = ... | 366 |
'''simple docstring'''
import warnings
from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor
lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__)
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
... | 37 | 0 |
'''simple docstring'''
import multiprocessing
import os
from typing import BinaryIO, Optional, Union
import fsspec
from .. import Dataset, Features, NamedSplit, config
from ..formatting import query_table
from ..packaged_modules.json.json import Json
from ..utils import logging
from ..utils.typing import Neste... | 367 |
'''simple docstring'''
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
... | 37 | 0 |
'''simple docstring'''
import math
def __UpperCamelCase ( _UpperCAmelCase = 100 ):
__UpperCAmelCase : List[Any] = sum(i * i for i in range(1, n + 1 ) )
__UpperCAmelCase : List[Any] = int(math.pow(sum(range(1, n + 1 ) ), 2 ) ... | 368 |
'''simple docstring'''
import argparse
import re
from flax.traverse_util import flatten_dict, unflatten_dict
from tax import checkpoints
from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration
from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc... | 37 | 0 |
'''simple docstring'''
from multiprocessing import Lock, Pipe, Process
# lock used to ensure that two processes do not access a pipe at the same time
lowerCAmelCase__ : Tuple = Lock()
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmel... | 369 |
'''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... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
import time
from math import sqrt
# 1 for manhattan, 0 for euclidean
lowerCAmelCase__ : List[Any] = 0
lowerCAmelCase__ : Union[str, Any] = [
[0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's ... | 370 |
'''simple docstring'''
from __future__ import annotations
import math
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
if depth < 0:
raise ValueError("Depth cannot be less than 0" )
if not scores:
raise ValueErro... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
return round(float(moles / volume ) * nfactor )
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
return round(float((moles * 0.0_821 * temperat... | 371 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : Dict = logging.get_logger(__name__)
lowerCAmelCase__ : int = {
"google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json",
"g... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
import collections
import pprint
from pathlib import Path
def __UpperCamelCase ( _UpperCAmelCase ):
return "".join(sorted(_UpperCAmelCase ) )
def __UpperCamelCase ( _UpperCAmelCase ):
return word_... | 350 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
try:
__UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase )
except ValueError:
raise ValueError("Please enter a valid number" )
__UpperCAmelCase : str = decimal - int(_U... | 37 | 0 |
'''simple docstring'''
import tempfile
import unittest
from pathlib import Path
from shutil import copyfile
from transformers import BatchEncoding, MarianTokenizer
from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow
from transformers.utils import is_sentencepiece_available, is_tf_a... | 351 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
if p < 2:
raise ValueError("p should not be less than 2!" )
elif p == 2:
return True
__UpperCAmelCase : List[str] = 4
__UpperCAmelCase : int = (1 << p) - 1
for _ in range(p - ... | 37 | 0 |
'''simple docstring'''
import re
from pathlib import Path
from unittest import TestCase
import pytest
@pytest.mark.integration
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
def lowerCamelCase_ ( self : List[Any] , UpperCAmelCase_ ... | 352 |
'''simple docstring'''
from collections.abc import Callable
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : float = a
__UpperCAmelCase : float = b
if function(_UpperCAmelCase ) == 0: # one of the a or... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
import unittest
import numpy as np
from transformers import OPTConfig, is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, slow
from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common impor... | 353 |
'''simple docstring'''
import unittest
from transformers import PegasusTokenizer, PegasusTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow
from transformers.utils import cached_property
from ...test_tokenization_common import Toke... | 37 | 0 |
'''simple docstring'''
lowerCAmelCase__ : int = "0.18.2"
from .configuration_utils import ConfigMixin
from .utils import (
OptionalDependencyNotAvailable,
is_flax_available,
is_inflect_available,
is_invisible_watermark_available,
is_k_diffusion_available,
is_k_diffusion_vers... | 354 |
'''simple docstring'''
from __future__ import annotations
import collections
import pprint
from pathlib import Path
def __UpperCamelCase ( _UpperCAmelCase ):
return "".join(sorted(_UpperCAmelCase ) )
def __UpperCamelCase ( _UpperCAmelCase ):
return word_by_signature[signatu... | 37 | 0 |
class SCREAMING_SNAKE_CASE__ :
"""simple docstring"""
def __init__( self : Dict , UpperCAmelCase_ : str = "" , UpperCAmelCase_ : bool = False ):
"""simple docstring"""
__UpperCAmelCase : dict[str, RadixNode] ... | 355 |
'''simple docstring'''
import collections
import inspect
import unittest
from transformers import SwinvaConfig
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_configurat... | 37 | 0 |
'''simple docstring'''
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps... | 356 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase ):
if not nums:
raise ValueError("List is empty" )
return sum(_UpperCAmelCase ) / len(_UpperCAmelCase )
if __name__ == "__main__":
import doctest
doctest.testmod()
| 37 | 0 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices
lowerCAmelCase__ : int = logging.get_logger(__name__)
lowerCAmelCase__ : Tuple =... | 357 |
'''simple docstring'''
#
# This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or
# many nodes) can talk to each other via nccl and allocate gpu memory.
#
# To run first adjust the number of processes and nodes:
#
# python -m torch.distributed.run --nproc_per_node 2 --nnod... | 37 | 0 |
'''simple docstring'''
import pickle
import numpy as np
from matplotlib import pyplot as plt
class SCREAMING_SNAKE_CASE__ :
"""simple docstring"""
def __init__( self : List[Any] , UpperCAmelCase_ : List[Any] , UpperCAmelCase_ : Dict , ... | 358 |
'''simple docstring'''
import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
SCREAMING_SNAKE_CASE = '''M-CLIP'''
def __init__( self : List[str] ,... | 37 | 0 |
'''simple docstring'''
from pickle import UnpicklingError
import jax
import jax.numpy as jnp
import numpy as np
from flax.serialization import from_bytes
from flax.traverse_util import flatten_dict
from ..utils import logging
lowerCAmelCase__ : Union[str, Any] = logging.get_logger(__name__)
de... | 359 |
'''simple docstring'''
import math
class SCREAMING_SNAKE_CASE__ :
"""simple docstring"""
def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1
"""simple docstring"""
__UpperCAmelCase :... | 37 | 0 |
'''simple docstring'''
from abc import ABC, abstractmethod
from argparse import ArgumentParser
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
@staticmethod
@abstractmethod
def lowerCamelCase_ ( UpperCAmelCase_ : ArgumentParser ... | 360 |
'''simple docstring'''
from datetime import datetime as dt
import os
from github import Github
lowerCAmelCase__ : Union[str, Any] = [
"good first issue",
"good second issue",
"good difficult issue",
"feature request",
"new model",
"wip",
]
def __UpperCamelCase ( ):
... | 37 | 0 |
'''simple docstring'''
import os
import sys
import transformers
lowerCAmelCase__ : Dict = "3"
print("Python version:", sys.version)
print("transformers version:", transformers.__version__)
try:
import torch
print("Torch version:", torch.__version__)
print("Cuda available:", torch.cuda... | 361 |
'''simple docstring'''
from heapq import heappop, heappush
import numpy as np
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ):
__UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape
__UpperCAmelCase : List[... | 37 | 0 |
from math import ceil
from typing import List, Optional, Union
import numpy as np
from ...audio_utils import mel_filter_bank, spectrogram, window_function
from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor
from ...utils import TensorType, logging
lowerCAmelCase__ : Opt... | 362 |
'''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_ber... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
__UpperCAmelCase : Any = n ** (1 / 3)
return (val * val * val) == n
if __name__ == "__main__":
print(perfect_cube(27))
print(perfect_cube(4))
| 363 |
'''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
#
... | 37 | 0 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : List[Any] = logging.get_logger(__name__)
lowerCAmelCase__ : List[Any] = {
"unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/... | 364 |
'''simple docstring'''
import argparse
import requests
import torch
from PIL import Image
from torchvision.transforms import Compose, Normalize, Resize, ToTensor
from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor
def __UpperCamelCase ( _UpperCAmelCase ):
... | 37 | 0 |
'''simple docstring'''
import os
import re
from shutil import copyfile
from typing import List, Optional, Tuple
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
lowerCAmelCase__ : Tuple = logging.get_logger(__name__)
lowerCAmelCase__ : Union[str, Any] ... | 365 |
'''simple docstring'''
import gc
import math
import unittest
import torch
from diffusers import UNetaDModel
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism
from .test_modeling_common import ModelTesterMix... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase ):
__UpperCAmelCase : Dict = 0.00
__UpperCAmelCase : Dict = 0
for resistor in resistors:
if resistor <= 0:
__UpperCAmelCase : Optional[Any] ... | 366 |
'''simple docstring'''
import warnings
from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor
lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__)
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
# 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
__UpperCAmelCase : int = gray_code_seque... | 367 |
'''simple docstring'''
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
... | 37 | 0 |
'''simple docstring'''
import json
import os
import tempfile
import transformers
import datasets
from utils import generate_example_dataset, get_duration
lowerCAmelCase__ : str = 50_00_00
lowerCAmelCase__ : Optional[int] = os.path.split(__file__)
lowerCAmelCase__ : Union[str, A... | 368 |
'''simple docstring'''
import argparse
import re
from flax.traverse_util import flatten_dict, unflatten_dict
from tax import checkpoints
from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration
from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc... | 37 | 0 |
'''simple docstring'''
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
lowerCAmelCase__ : Any = logging.get_logger(__name__)
lowerCAmelCase__ ... | 369 |
'''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... | 37 | 0 |
'''simple docstring'''
from ....configuration_utils import PretrainedConfig
from ....utils import logging
lowerCAmelCase__ : Union[str, Any] = logging.get_logger(__name__)
lowerCAmelCase__ : Optional[Any] = {
"speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-... | 370 |
'''simple docstring'''
from __future__ import annotations
import math
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
if depth < 0:
raise ValueError("Depth cannot be less than 0" )
if not scores:
raise ValueErro... | 37 | 0 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices
lowerCAmelCase__ : Any = logging.get_logger(__name__)
lowerCAmelCase__ : Optional[int] ... | 371 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : Dict = logging.get_logger(__name__)
lowerCAmelCase__ : int = {
"google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json",
"g... | 37 | 0 |
'''simple docstring'''
import functools
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ):
# Validation
if not isinstance(_UpperCAmelCase, _UpperCAmelCase ) or not all(isinstance(_UpperCAmelCase, _UpperCAmelCase ) for day in days ):
raise ValueEr... | 350 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
try:
__UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase )
except ValueError:
raise ValueError("Please enter a valid number" )
__UpperCAmelCase : str = decimal - int(_U... | 37 | 0 |
'''simple docstring'''
import functools
import operator
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : List[str] = logging.get_logger(__name__)
lowerCAmelCase__ : Any = {
"microsoft/unispeech-large-1500h-cv": (
"https:... | 351 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
if p < 2:
raise ValueError("p should not be less than 2!" )
elif p == 2:
return True
__UpperCAmelCase : List[str] = 4
__UpperCAmelCase : int = (1 << p) - 1
for _ in range(p - ... | 37 | 0 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : Union[str, Any] = set(_UpperCAmelCase ), [start]
while stack:
__UpperCAmelCase : List[str] = stack.pop()
explor... | 352 |
'''simple docstring'''
from collections.abc import Callable
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : float = a
__UpperCAmelCase : float = b
if function(_UpperCAmelCase ) == 0: # one of the a or... | 37 | 0 |
'''simple docstring'''
from cva import destroyAllWindows, imread, imshow, waitKey
def __UpperCamelCase ( _UpperCAmelCase ):
# getting number of pixels in the image
__UpperCAmelCase : Dict = img.shape[0], img.shape[1]
# converting each pixel's color to its negative
for i in range(... | 353 |
'''simple docstring'''
import unittest
from transformers import PegasusTokenizer, PegasusTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow
from transformers.utils import cached_property
from ...test_tokenization_common import Toke... | 37 | 0 |
'''simple docstring'''
import collections
import inspect
import unittest
from transformers import SwinvaConfig
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_configurat... | 354 |
'''simple docstring'''
from __future__ import annotations
import collections
import pprint
from pathlib import Path
def __UpperCamelCase ( _UpperCAmelCase ):
return "".join(sorted(_UpperCAmelCase ) )
def __UpperCamelCase ( _UpperCAmelCase ):
return word_by_signature[signatu... | 37 | 0 |
from abc import ABC, abstractmethod
from typing import Optional, Union
from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit
from ..utils.typing import NestedDataStructureLike, PathLike
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple... | 355 |
'''simple docstring'''
import collections
import inspect
import unittest
from transformers import SwinvaConfig
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_configurat... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ):
return base * power(_UpperCAmelCase, (exponent - 1) ) if exponent else 1
if __name__ == "__main__":
print("Raise base to the power of exponent using recursion...")
lowerCAmelCase__ : Union[str, Any... | 356 |
'''simple docstring'''
from __future__ import annotations
def __UpperCamelCase ( _UpperCAmelCase ):
if not nums:
raise ValueError("List is empty" )
return sum(_UpperCAmelCase ) / len(_UpperCAmelCase )
if __name__ == "__main__":
import doctest
doctest.testmod()
| 37 | 0 |
'''simple docstring'''
import numpy as np
import qiskit
def __UpperCamelCase ( _UpperCAmelCase = 8, _UpperCAmelCase = None ):
__UpperCAmelCase : Union[str, Any] = np.random.default_rng(seed=_UpperCAmelCase )
# Roughly 25% of the qubits will contribute to the key.
# So... | 357 |
'''simple docstring'''
#
# This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or
# many nodes) can talk to each other via nccl and allocate gpu memory.
#
# To run first adjust the number of processes and nodes:
#
# python -m torch.distributed.run --nproc_per_node 2 --nnod... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
try:
__UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase )
except ValueError:
raise ValueError("Please enter a valid number" )
__UpperCAmelCase : str = decimal - int(_U... | 358 |
'''simple docstring'''
import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
SCREAMING_SNAKE_CASE = '''M-CLIP'''
def __init__( self : List[str] ,... | 37 | 0 |
'''simple docstring'''
import PIL.Image
import PIL.ImageOps
from packaging import version
from PIL import Image
if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"):
lowerCAmelCase__ : Tuple = {
"linear": PIL.Image.Resampling.BILINEAR,
"bilinear"... | 359 |
'''simple docstring'''
import math
class SCREAMING_SNAKE_CASE__ :
"""simple docstring"""
def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1
"""simple docstring"""
__UpperCAmelCase :... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
__UpperCAmelCase : Union[str, Any] = 0
# if input_string is "aba" than new_input_string become "a|b|a"
__UpperCAmelCase : Any = ""
__UpperCAmelCase : List[Any] = ""
# append ... | 360 |
'''simple docstring'''
from datetime import datetime as dt
import os
from github import Github
lowerCAmelCase__ : Union[str, Any] = [
"good first issue",
"good second issue",
"good difficult issue",
"feature request",
"new model",
"wip",
]
def __UpperCamelCase ( ):
... | 37 | 0 |
'''simple docstring'''
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_torch_available,
is_vision_available,
)
lowerCAmelCase__ : Any = {
"configuration_mobilevit": ["MOBILEVIT_PRETRAINED_CONFIG_ARCHI... | 361 |
'''simple docstring'''
from heapq import heappop, heappush
import numpy as np
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ):
__UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape
__UpperCAmelCase : List[... | 37 | 0 |
from __future__ import annotations
from fractions import Fraction
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ):
return (
num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den
)
def __UpperCamelCase ( _UpperCAmelCase ):
__UpperCAmelCase ... | 362 |
'''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_ber... | 37 | 0 |
'''simple docstring'''
from math import factorial
lowerCAmelCase__ : Optional[Any] = {str(d): factorial(d) for d in range(10)}
def __UpperCamelCase ( _UpperCAmelCase ):
return sum(DIGIT_FACTORIAL[d] for d in str(_UpperCAmelCase ) )
def __UpperCamelCase ( ):
__UpperCA... | 363 |
'''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
#
... | 37 | 0 |
'''simple docstring'''
lowerCAmelCase__ : int = {
"Pillow": "Pillow<10.0.0",
"accelerate": "accelerate>=0.20.3",
"av": "av==9.2.0",
"beautifulsoup4": "beautifulsoup4",
"black": "black~=23.1",
"codecarbon": "codecarbon==1.2.0",
"cookiecutter": "cookiecutter==1.7.3",
"d... | 364 |
'''simple docstring'''
import argparse
import requests
import torch
from PIL import Image
from torchvision.transforms import Compose, Normalize, Resize, ToTensor
from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor
def __UpperCamelCase ( _UpperCAmelCase ):
... | 37 | 0 |
'''simple docstring'''
from urllib.parse import quote
import pytest
from datasets.utils.hub import hf_hub_url
@pytest.mark.parametrize("repo_id", ["canonical_dataset_name", "org-name/dataset-name"] )
@pytest.mark.parametrize("path", ["filename.csv", "filename with blanks.csv"] )
@pytest.mark.... | 365 |
'''simple docstring'''
import gc
import math
import unittest
import torch
from diffusers import UNetaDModel
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism
from .test_modeling_common import ModelTesterMix... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
__UpperCAmelCase : int = 0
while num > 0:
digit_sum += num % 10
num //= 10
return digit_sum
def __UpperCamelCase ( _UpperCAmelCase = 100 ):
__UpperCAmelCase : Any = 1
__Upp... | 366 |
'''simple docstring'''
import warnings
from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor
lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__)
class SCREAMING_SNAKE_CASE__ ( snake_case__ ):
"""simple docstring"""
... | 37 | 0 |
'''simple docstring'''
import os
from shutil import copyfile
from typing import List, Optional, Tuple
from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging
if is_sentencepiece_available():
from .t... | 367 |
'''simple docstring'''
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
... | 37 | 0 |
'''simple docstring'''
import argparse
import re
from flax.traverse_util import flatten_dict, unflatten_dict
from tax import checkpoints
from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration
from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc... | 368 |
'''simple docstring'''
import argparse
import re
from flax.traverse_util import flatten_dict, unflatten_dict
from tax import checkpoints
from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration
from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc... | 37 | 0 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
__UpperCAmelCase : Tuple = hex_num.strip()
if not hex_num:
raise ValueError("No value was passed to the function" )
__UpperCAmelCase : List[Any] = hex_num[0] == "-"
if is_negative:
... | 369 |
'''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... | 37 | 0 |
'''simple docstring'''
from ..utils import DummyObject, requires_backends
class SCREAMING_SNAKE_CASE__ ( metaclass=snake_case__ ):
"""simple docstring"""
SCREAMING_SNAKE_CASE = ['''keras_nlp''']
def __init__( self : Dict , *UpperCAmelCase_ : ... | 370 |
'''simple docstring'''
from __future__ import annotations
import math
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
if depth < 0:
raise ValueError("Depth cannot be less than 0" )
if not scores:
raise ValueErro... | 37 | 0 |
'''simple docstring'''
import gc
import math
import unittest
import torch
from diffusers import UNetaDModel
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism
from .test_modeling_common import ModelTesterMix... | 371 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCAmelCase__ : Dict = logging.get_logger(__name__)
lowerCAmelCase__ : int = {
"google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json",
"g... | 37 | 0 |
'''simple docstring'''
import argparse
import glob
import logging
import os
import time
from argparse import Namespace
import numpy as np
import torch
from lightning_base import BaseTransformer, add_generic_args, generic_train
from torch.utils.data import DataLoader, TensorDataset
from tran... | 350 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
try:
__UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase )
except ValueError:
raise ValueError("Please enter a valid number" )
__UpperCAmelCase : str = decimal - int(_U... | 37 | 0 |
'''simple docstring'''
import uuid
from typing import Any, Dict, List, Optional, Union
from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline
if is_tf_available():
import tensorflow as tf
if is_torch_available():
import torch
... | 351 |
'''simple docstring'''
def __UpperCamelCase ( _UpperCAmelCase ):
if p < 2:
raise ValueError("p should not be less than 2!" )
elif p == 2:
return True
__UpperCAmelCase : List[str] = 4
__UpperCAmelCase : int = (1 << p) - 1
for _ in range(p - ... | 37 | 0 |
'''simple docstring'''
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging
lowerCAmelCase__ : str = logging.get_logger(__name__)
lowerCAme... | 352 |
'''simple docstring'''
from collections.abc import Callable
def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ):
__UpperCAmelCase : float = a
__UpperCAmelCase : float = b
if function(_UpperCAmelCase ) == 0: # one of the a or... | 37 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.