sample_id
stringlengths
21
196
text
stringlengths
105
936k
metadata
dict
category
stringclasses
6 values
keras-team/keras:keras/src/quantizers/awq.py
"""AWQ (Activation-aware Weight Quantization) algorithm implementation. AWQ protects salient weights by finding optimal per-channel scales based on activation magnitudes, then applies those scales before quantization. Reference: https://arxiv.org/abs/2306.00978 """ import types from keras.src import ops from keras....
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/awq.py", "license": "Apache License 2.0", "lines": 296, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/quantizers/awq_config.py
from keras.src.api_export import keras_export from keras.src.quantizers.quantization_config import QuantizationConfig @keras_export("keras.quantizers.AWQConfig") class AWQConfig(QuantizationConfig): """Configuration class for AWQ (Activation-aware Weight Quantization). AWQ is a post-training quantization met...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/awq_config.py", "license": "Apache License 2.0", "lines": 123, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/quantizers/awq_config_test.py
import pytest from keras.src import testing from keras.src.quantizers.awq_config import AWQConfig @pytest.mark.requires_trainable_backend class AWQConfigTest(testing.TestCase): """Test AWQConfig validation and serialization.""" class MockTokenizer: """Mock tokenizer for testing purposes.""" ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/awq_config_test.py", "license": "Apache License 2.0", "lines": 121, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/quantizers/awq_core.py
"""AWQ core functionality for layer-wise quantization. This module provides the orchestration logic for applying AWQ quantization to transformer models in a layer-by-layer fashion. """ from contextlib import contextmanager from absl import logging from keras.src import ops from keras.src import utils as keras_utils...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/awq_core.py", "license": "Apache License 2.0", "lines": 175, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/saving/orbax_util.py
"""Orbax checkpoint loading functionality.""" import os from keras.src.utils import file_utils from keras.src.utils.module_utils import ocp def is_orbax_checkpoint(filepath): """Check if the given path is an Orbax checkpoint directory. This function implements custom detection logic instead of relying on ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/saving/orbax_util.py", "license": "Apache License 2.0", "lines": 42, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
keras-team/keras:keras/src/layers/pooling/adaptive_average_pooling1d.py
"""Adaptive Average Pooling 1D layer.""" from keras.src.api_export import keras_export from keras.src.layers.pooling.base_adaptive_pooling import ( BaseAdaptiveAveragePooling, ) @keras_export("keras.layers.AdaptiveAveragePooling1D") class AdaptiveAveragePooling1D(BaseAdaptiveAveragePooling): """Adaptive aver...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_average_pooling1d.py", "license": "Apache License 2.0", "lines": 55, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/layers/pooling/adaptive_average_pooling2d.py
"""Adaptive Average Pooling 2D layer.""" from keras.src.api_export import keras_export from keras.src.layers.pooling.base_adaptive_pooling import ( BaseAdaptiveAveragePooling, ) @keras_export("keras.layers.AdaptiveAveragePooling2D") class AdaptiveAveragePooling2D(BaseAdaptiveAveragePooling): """Adaptive aver...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_average_pooling2d.py", "license": "Apache License 2.0", "lines": 52, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/layers/pooling/adaptive_average_pooling3d.py
"""Adaptive Average Pooling 3D layer.""" from keras.src.api_export import keras_export from keras.src.layers.pooling.base_adaptive_pooling import ( BaseAdaptiveAveragePooling, ) @keras_export("keras.layers.AdaptiveAveragePooling3D") class AdaptiveAveragePooling3D(BaseAdaptiveAveragePooling): """Adaptive aver...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_average_pooling3d.py", "license": "Apache License 2.0", "lines": 53, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/layers/pooling/adaptive_max_pooling1d.py
"""Adaptive Max Pooling 1D layer.""" from keras.src.api_export import keras_export from keras.src.layers.pooling.base_adaptive_pooling import ( BaseAdaptiveMaxPooling, ) @keras_export("keras.layers.AdaptiveMaxPooling1D") class AdaptiveMaxPooling1D(BaseAdaptiveMaxPooling): """Adaptive max pooling operation fo...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_max_pooling1d.py", "license": "Apache License 2.0", "lines": 55, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/layers/pooling/adaptive_max_pooling2d.py
"""Adaptive Max Pooling 2D layer.""" from keras.src.api_export import keras_export from keras.src.layers.pooling.base_adaptive_pooling import ( BaseAdaptiveMaxPooling, ) @keras_export("keras.layers.AdaptiveMaxPooling2D") class AdaptiveMaxPooling2D(BaseAdaptiveMaxPooling): """Adaptive max pooling operation fo...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_max_pooling2d.py", "license": "Apache License 2.0", "lines": 52, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/layers/pooling/adaptive_max_pooling3d.py
"""Adaptive Max Pooling 3D layer.""" from keras.src.api_export import keras_export from keras.src.layers.pooling.base_adaptive_pooling import ( BaseAdaptiveMaxPooling, ) @keras_export("keras.layers.AdaptiveMaxPooling3D") class AdaptiveMaxPooling3D(BaseAdaptiveMaxPooling): """Adaptive max pooling operation fo...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_max_pooling3d.py", "license": "Apache License 2.0", "lines": 53, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/layers/pooling/adaptive_pooling1d_test.py
import numpy as np import pytest from keras.src import backend from keras.src import layers from keras.src import testing SKIP_BACKENDS = ["openvino"] pytestmark = pytest.mark.skipif( backend.backend() in SKIP_BACKENDS, reason=( "Adaptive pooling tests not supported for backend: {}".format( ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_pooling1d_test.py", "license": "Apache License 2.0", "lines": 112, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/layers/pooling/adaptive_pooling2d_test.py
import numpy as np import pytest from keras.src import backend from keras.src import layers from keras.src import testing SKIP_BACKENDS = ["openvino"] pytestmark = pytest.mark.skipif( backend.backend() in SKIP_BACKENDS, reason=( "Adaptive pooling tests not supported for backend: {}".format( ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_pooling2d_test.py", "license": "Apache License 2.0", "lines": 156, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/layers/pooling/adaptive_pooling3d_test.py
import numpy as np import pytest from keras.src import backend from keras.src import layers from keras.src import testing SKIP_BACKENDS = ["openvino"] pytestmark = pytest.mark.skipif( backend.backend() in SKIP_BACKENDS, reason=( "Adaptive pooling tests not supported for backend: {}".format( ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/adaptive_pooling3d_test.py", "license": "Apache License 2.0", "lines": 144, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/layers/pooling/base_adaptive_pooling.py
"""Base classes for adaptive pooling layers.""" from keras.src import ops from keras.src.backend import config from keras.src.layers.layer import Layer class BaseAdaptivePooling(Layer): """Base class shared by all adaptive pooling layers.""" def __init__(self, output_size, data_format=None, **kwargs): ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/pooling/base_adaptive_pooling.py", "license": "Apache License 2.0", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
keras-team/keras:keras/src/quantizers/quantization_config.py
from keras.src.api_export import keras_export from keras.src.dtype_policies import QUANTIZATION_MODES from keras.src.saving import serialization_lib @keras_export("keras.quantizers.QuantizationConfig") class QuantizationConfig: """Base class for quantization configs. Subclasses must implement the `mode` prop...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/quantization_config.py", "license": "Apache License 2.0", "lines": 284, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/quantizers/quantization_config_test.py
import os from keras.src import layers from keras.src import models from keras.src import saving from keras.src import testing from keras.src.quantizers.quantization_config import Int4QuantizationConfig from keras.src.quantizers.quantization_config import Int8QuantizationConfig from keras.src.quantizers.quantization_c...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/quantization_config_test.py", "license": "Apache License 2.0", "lines": 187, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/quantizers/utils_test.py
from absl.testing import parameterized from keras.src import layers from keras.src import testing from keras.src.quantizers import utils class UtilsTest(testing.TestCase): @parameterized.named_parameters( ("none_filter", None, "dense", True), ("regex_match", "dense", "dense_1", True), ("r...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/utils_test.py", "license": "Apache License 2.0", "lines": 17, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/export/litert.py
from keras.src import layers from keras.src import models from keras.src import tree from keras.src.export.export_utils import get_input_signature from keras.src.utils import io_utils from keras.src.utils.module_utils import tensorflow as tf def export_litert( model, filepath, input_signature=None, **...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/export/litert.py", "license": "Apache License 2.0", "lines": 205, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/export/litert_test.py
import os import numpy as np import pytest from absl.testing import parameterized from keras.src import backend from keras.src import layers from keras.src import models from keras.src import ops from keras.src import testing from keras.src import tree from keras.src.saving import saving_lib from keras.src.testing.te...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/export/litert_test.py", "license": "Apache License 2.0", "lines": 1079, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/callbacks/orbax_checkpoint.py
import warnings import numpy as np from keras.src import backend from keras.src import tree from keras.src.api_export import keras_export from keras.src.callbacks.monitor_callback import ( MonitorCallback, # For metric monitoring logic ) from keras.src.saving import saving_lib from keras.src.utils.module_utils i...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/callbacks/orbax_checkpoint.py", "license": "Apache License 2.0", "lines": 321, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/callbacks/orbax_checkpoint_test.py
import os import numpy as np import pytest from absl.testing import parameterized from keras.src import backend from keras.src import layers from keras.src import models from keras.src import saving from keras.src import testing from keras.src import utils from keras.src.callbacks.orbax_checkpoint import OrbaxCheckpo...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/callbacks/orbax_checkpoint_test.py", "license": "Apache License 2.0", "lines": 491, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/utils/progbar_test.py
import numpy as np from absl.testing import parameterized from keras.src import testing from keras.src.utils import progbar class ProgbarTest(testing.TestCase): @parameterized.named_parameters( [ ("float", "float"), ("np", "np"), ("list", "list"), ] ) d...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/utils/progbar_test.py", "license": "Apache License 2.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/utils/image_utils_test.py
import os import numpy as np from absl.testing import parameterized from keras.src import testing from keras.src.utils import img_to_array from keras.src.utils import load_img from keras.src.utils import save_img class SaveImgTest(testing.TestCase, parameterized.TestCase): @parameterized.named_parameters( ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/utils/image_utils_test.py", "license": "Apache License 2.0", "lines": 28, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/distillation/distillation_loss.py
import keras from keras.src import tree from keras.src.api_export import keras_export from keras.src.saving import serialization_lib from keras.src.utils import tracking def _convert_loss_to_function(loss_item): """Convert a loss string identifier to a loss function. Arguments: loss_item: Either a st...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/distillation/distillation_loss.py", "license": "Apache License 2.0", "lines": 324, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/distillation/distillation_loss_test.py
import numpy as np import pytest import keras from keras.src.distillation.distillation_loss import FeatureDistillation from keras.src.distillation.distillation_loss import LogitsDistillation from keras.src.distillation.distiller import Distiller from keras.src.testing import TestCase @pytest.mark.requires_trainable_...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/distillation/distillation_loss_test.py", "license": "Apache License 2.0", "lines": 192, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/distillation/distiller.py
import keras from keras.src import tree from keras.src.api_export import keras_export from keras.src.distillation.distillation_loss import _convert_loss_to_function from keras.src.models.model import Model from keras.src.saving import serialization_lib @keras_export("keras.distillation.Distiller") class Distiller(Mod...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/distillation/distiller.py", "license": "Apache License 2.0", "lines": 520, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/distillation/distiller_test.py
import json import os import numpy as np import pytest import keras from keras.src.distillation.distillation_loss import LogitsDistillation from keras.src.distillation.distiller import Distiller from keras.src.testing import TestCase class SimpleTeacher(keras.Model): """Simple teacher model for testing.""" ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/distillation/distiller_test.py", "license": "Apache License 2.0", "lines": 430, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/layers/core/reversible_embedding.py
import copy import math from keras.src import dtype_policies from keras.src import layers from keras.src import ops from keras.src import quantizers from keras.src.api_export import keras_export from keras.src.backend import KerasTensor from keras.src.backend import set_keras_mask from keras.src.quantizers.quantizatio...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/core/reversible_embedding.py", "license": "Apache License 2.0", "lines": 489, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/layers/core/reversible_embedding_test.py
import math import os import numpy as np import pytest from absl.testing import parameterized from keras.src import backend from keras.src import layers from keras.src import models from keras.src import ops from keras.src import saving from keras.src import testing from keras.src.quantizers.quantization_config impor...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/core/reversible_embedding_test.py", "license": "Apache License 2.0", "lines": 444, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/tree/torchtree_impl.py
from collections import defaultdict from torch.utils import _pytree as torch_tree def register_tree_node_class(cls): torch_tree.register_pytree_node( cls, flatten_fn=lambda x: x.torchtree_flatten(), unflatten_fn=cls.torchtree_unflatten, serialized_type_name=f"{cls.__name__}", ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/tree/torchtree_impl.py", "license": "Apache License 2.0", "lines": 173, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/quantizers/gptq_config_test.py
from keras.src import testing from keras.src.quantizers.gptq_config import GPTQConfig class TestGPTQConfig(testing.TestCase): def test_invalid_weight_bits(self): with self.assertRaisesRegex(ValueError, "Unsupported weight_bits"): GPTQConfig(dataset=None, tokenizer=None, weight_bits=1) ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/gptq_config_test.py", "license": "Apache License 2.0", "lines": 52, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/validation_test.py
import pytest import tensorflow as tf from keras.src import backend from keras.src.layers.preprocessing.image_preprocessing.bounding_boxes import ( validation, ) from keras.src.testing import test_case @pytest.mark.skipif( backend.backend() != "tensorflow", reason="The test targets TensorFlow-specific ra...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/validation_test.py", "license": "Apache License 2.0", "lines": 70, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template"...
test
keras-team/keras:keras/src/quantizers/gptq.py
import types from keras.src import ops from keras.src import quantizers from keras.src.layers import Dense from keras.src.layers import EinsumDense from keras.src.ops import linalg from keras.src.quantizers.gptq_config import GPTQConfig from keras.src.quantizers.quantizers import GPTQQuantizer from keras.src.quantizer...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/gptq.py", "license": "Apache License 2.0", "lines": 432, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/quantizers/gptq_config.py
from keras.src.api_export import keras_export from keras.src.quantizers.quantization_config import QuantizationConfig @keras_export("keras.quantizers.GPTQConfig") class GPTQConfig(QuantizationConfig): """Configuration class for the GPTQ (Gradient-based Post-Training Quantization) algorithm. GPTQ is a pos...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/gptq_config.py", "license": "Apache License 2.0", "lines": 196, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/quantizers/gptq_core.py
import math from contextlib import contextmanager import numpy as np from absl import logging from keras.src import ops from keras.src import utils as keras_utils from keras.src.dtype_policies.dtype_policy import GPTQDTypePolicy from keras.src.dtype_policies.dtype_policy_map import DTypePolicyMap from keras.src.layer...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/gptq_core.py", "license": "Apache License 2.0", "lines": 380, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/quantizers/gptq_core_test.py
import numpy as np import pytest from absl.testing import parameterized from keras.src import layers from keras.src import models from keras.src import ops from keras.src import testing from keras.src.quantizers.gptq_config import GPTQConfig from keras.src.quantizers.gptq_core import get_dataloader from keras.src.quan...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/gptq_core_test.py", "license": "Apache License 2.0", "lines": 273, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/quantizers/gptq_test.py
from collections.abc import Callable import numpy as np import pytest from absl.testing import parameterized import keras from keras.src import backend from keras.src import layers from keras.src import models from keras.src import ops from keras.src import testing from keras.src.quantizers.gptq import GPTQ from kera...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/quantizers/gptq_test.py", "license": "Apache License 2.0", "lines": 606, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/layers/preprocessing/data_layer.py
import keras.src.backend from keras.src import tree from keras.src.layers.layer import Layer from keras.src.random.seed_generator import SeedGenerator from keras.src.utils import backend_utils from keras.src.utils import jax_utils from keras.src.utils import tracking class DataLayer(Layer): """Layer designed for ...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/preprocessing/data_layer.py", "license": "Apache License 2.0", "lines": 133, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
keras-team/keras:keras/src/layers/preprocessing/data_layer_test.py
import grain import numpy as np import pytest from tensorflow import data as tf_data from keras.src import backend from keras.src import testing from keras.src.layers.preprocessing.data_layer import DataLayer from keras.src.random import SeedGenerator class RandomRGBToHSVLayer(DataLayer): def __init__(self, data...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/layers/preprocessing/data_layer_test.py", "license": "Apache License 2.0", "lines": 77, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/utils/grain_utils.py
from keras.src import backend from keras.src import tree def make_batch(values): from keras.src import ops if not values: raise ValueError("Cannot batch 0 values. Please file a bug.") with backend.device_scope("cpu"): return tree.map_structure(lambda *xs: ops.stack(xs), *values) def ma...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/utils/grain_utils.py", "license": "Apache License 2.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
keras-team/keras:keras/src/backend/jax/core_test.py
import os import jax import jax.numpy as jnp import numpy as np import pytest import keras from keras.src import backend from keras.src import testing from keras.src.backend.config import is_nnx_enabled if is_nnx_enabled(): from flax import nnx from keras.src.backend.jax.core import NnxVariable @pytest.ma...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/backend/jax/core_test.py", "license": "Apache License 2.0", "lines": 56, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/export/openvino.py
import warnings from keras.src import backend from keras.src import tree from keras.src.export.export_utils import convert_spec_to_tensor from keras.src.export.export_utils import get_input_signature from keras.src.export.export_utils import make_tf_tensor_spec from keras.src.export.saved_model import DEFAULT_ENDPOINT...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/export/openvino.py", "license": "Apache License 2.0", "lines": 175, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/export/openvino_test.py
import os import numpy as np import pytest from absl.testing import parameterized from keras.src import backend from keras.src import layers from keras.src import models from keras.src import ops from keras.src import testing from keras.src import tree from keras.src.export import openvino from keras.src.saving impor...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/export/openvino_test.py", "license": "Apache License 2.0", "lines": 216, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/trainers/data_adapters/grain_dataset_adapter.py
import itertools import numpy as np from keras.src import tree from keras.src.trainers.data_adapters import data_adapter_utils from keras.src.trainers.data_adapters.data_adapter import DataAdapter from keras.src.utils.module_utils import grain from keras.src.utils.module_utils import tensorflow as tf class GrainDat...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/trainers/data_adapters/grain_dataset_adapter.py", "license": "Apache License 2.0", "lines": 189, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/trainers/data_adapters/grain_dataset_adapter_test.py
import grain import numpy as np import tensorflow as tf import torch from absl.testing import parameterized from keras.src import backend from keras.src import testing from keras.src.testing.test_utils import named_product from keras.src.trainers.data_adapters import grain_dataset_adapter class Range2DSource(grain.s...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/trainers/data_adapters/grain_dataset_adapter_test.py", "license": "Apache License 2.0", "lines": 190, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/ops/ops_test.py
import inspect from absl.testing import parameterized try: from keras.api import ops as api_ops_root except ImportError: from keras import ops as api_ops_root from keras.src import backend from keras.src import ops from keras.src import testing from keras.src.ops.operation import Operation from keras.src.tes...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/ops/ops_test.py", "license": "Apache License 2.0", "lines": 241, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
keras-team/keras:keras/src/callbacks/monitor_callback.py
import warnings from keras.src import ops from keras.src.callbacks.callback import Callback from keras.src.trainers import compile_utils class MonitorCallback(Callback): """Base class for callbacks that monitor a quantity and evaluates improvements. This class provides common functionality for callbacks...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/callbacks/monitor_callback.py", "license": "Apache License 2.0", "lines": 94, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
keras-team/keras:keras/src/callbacks/monitor_callback_test.py
import numpy as np import pytest from keras.src import callbacks from keras.src import layers from keras.src import metrics from keras.src import models from keras.src import ops from keras.src import testing class MonitorCallbackTest(testing.TestCase): @pytest.mark.requires_trainable_backend def test_monito...
{ "repo_id": "keras-team/keras", "file_path": "keras/src/callbacks/monitor_callback_test.py", "license": "Apache License 2.0", "lines": 80, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
kovidgoyal/calibre:src/calibre/gui2/preferences/look_feel_tabs/font_selection_dialog.py
from qt.core import QDialog, QDialogButtonBox, QFontDatabase, QFontInfo, QHBoxLayout, QLabel, QListWidget, Qt, QVBoxLayout, QWidget, pyqtSignal class FontSelectionDialog(QDialog): fontSelected = pyqtSignal(str, str) # family, style def __init__(self, family: str = '', style: str = '', min_size=8, medium_siz...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/preferences/look_feel_tabs/font_selection_dialog.py", "license": "GNU General Public License v3.0", "lines": 166, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template"...
function_complex
kovidgoyal/calibre:src/calibre/utils/translator/test_translator.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2026, Kovid Goyal <kovid at kovidgoyal.net> import gettext import io import unittest import zipfile from calibre.utils.localization import available_translations, get_lc_messages_path from calibre_extensions.translator import Translator class TestTranslator(unittest...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/utils/translator/test_translator.py", "license": "GNU General Public License v3.0", "lines": 51, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
kovidgoyal/calibre:.github/workflows/macos_crash_report.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net> import json import posixpath import sys from collections import namedtuple from collections.abc import Mapping from datetime import datetime from enum import Enum from functools import cached_property from typing import IO F...
{ "repo_id": "kovidgoyal/calibre", "file_path": ".github/workflows/macos_crash_report.py", "license": "GNU General Public License v3.0", "lines": 389, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/db/tests/page_counts.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import io from calibre.db.tests.base import BaseTest class PageCountTest(BaseTest): ae = BaseTest.assertEqual def test_page_count_in_db(self): test_page_count_in_db(self) def test_page_count(self): ...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/db/tests/page_counts.py", "license": "GNU General Public License v3.0", "lines": 71, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
kovidgoyal/calibre:src/calibre/db/page_count.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import os import sys import weakref from collections.abc import Iterator from contextlib import suppress from queue import Queue, ShutDown from threading import Event, Thread, current_thread from typing import TYPE_CHECKING ...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/db/page_count.py", "license": "GNU General Public License v3.0", "lines": 163, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/library/page_count.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import os import subprocess import sys from concurrent.futures import Executor, ThreadPoolExecutor from contextlib import closing, suppress from math import ceil from multiprocessing import Pipe from operator import itemgette...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/library/page_count.py", "license": "GNU General Public License v3.0", "lines": 254, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/library/bookshelf_view.py
#!/usr/bin/env python # License: GPLv3 # Copyright: Andy C <achuongdev@gmail.com>, un_pogaz <un.pogaz@gmail.com>, Kovid Goyal <kovid@kovidgoyal.net> # Imports {{{ import bisect import math import random import struct import weakref from collections.abc import Iterable, Iterator from contextlib import suppress from fun...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/library/bookshelf_view.py", "license": "GNU General Public License v3.0", "lines": 2309, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/momentum_scroll.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from collections import deque from typing import NamedTuple from qt.core import ( QAbstractScrollArea, QElapsedTimer, QGroupBox, QHBoxLayout, QLabel, QListView, QMainWindow, QSlider, QStri...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/momentum_scroll.py", "license": "GNU General Public License v3.0", "lines": 357, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/preferences/look_feel_tabs/bookshelf_view.py
#!/usr/bin/env python __license__ = 'GPL v3' __copyright__ = '2025, Kovid Goyal <kovid@kovidgoyal.net>' __docformat__ = 'restructuredtext en' import os from contextlib import suppress from functools import lru_cache, partial from qt.core import QDialog, QDialogButtonBox, QFontInfo, QIcon, QInputDialog, QLabel, Qt...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/preferences/look_feel_tabs/bookshelf_view.py", "license": "GNU General Public License v3.0", "lines": 288, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/actions/llm_book.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from functools import partial from calibre.gui2 import error_dialog from calibre.gui2.actions import InterfaceAction class LLMBookAction(InterfaceAction): name = 'Discuss book with AI' action_spec = (_('Discuss b...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/actions/llm_book.py", "license": "GNU General Public License v3.0", "lines": 42, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
kovidgoyal/calibre:src/calibre/ai/lm_studio/backend.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Ali Sheikhizadeh (Al00X) <al00x@outlook.com> <https://al00x.com> # Based on code Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import json import posixpath from collections.abc import Iterable, Iterator from functools import lru_cache from typing import ...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/lm_studio/backend.py", "license": "GNU General Public License v3.0", "lines": 98, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/lm_studio/config.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Ali Sheikhizadeh (Al00X) <al00x@outlook.com> <https://al00x.com> # Based on code Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from functools import partial from typing import Any from qt.core import QComboBox, QCompleter, QDoubleSpinBox, QFormLayout, Q...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/lm_studio/config.py", "license": "GNU General Public License v3.0", "lines": 133, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/dialogs/llm_book.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from collections.abc import Iterator from functools import lru_cache from typing import Any from qt.core import QAbstractItemView, QDialog, QDialogButtonBox, QLabel, QListWidget, QListWidgetItem, QSize, Qt, QUrl, QVBoxLayout...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/dialogs/llm_book.py", "license": "GNU General Public License v3.0", "lines": 237, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/llm.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import textwrap from collections.abc import Iterator from html import escape from itertools import count from threading import Thread from typing import Any, NamedTuple from qt.core import ( QAbstractItemView, QAppli...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/llm.py", "license": "GNU General Public License v3.0", "lines": 654, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:setup/git_hooks.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, un_pogaz <un.pogaz@gmail.com> import os from contextlib import suppress from typing import NamedTuple from setup import Command HOOK_TEMPLATE = '''\ #!/usr/bin/env -S calibre-debug -e -- -- # File generated by calibre "setup.py git_hooks" import os import runp...
{ "repo_id": "kovidgoyal/calibre", "file_path": "setup/git_hooks.py", "license": "GNU General Public License v3.0", "lines": 108, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/ollama/backend.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import datetime import http import json import posixpath from collections.abc import Iterable, Iterator, Sequence from contextlib import suppress from functools import lru_cache from typing import Any, NamedTuple from urllib....
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/ollama/backend.py", "license": "GNU General Public License v3.0", "lines": 134, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/ollama/config.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from functools import partial from qt.core import QFormLayout, QLabel, QLineEdit, QPlainTextEdit, QSpinBox, QWidget from calibre.ai.ollama import OllamaAI from calibre.ai.prefs import pref_for_provider, set_prefs_for_provid...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/ollama/config.py", "license": "GNU General Public License v3.0", "lines": 113, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/openai/backend.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import datetime import json import os from collections.abc import Iterable, Iterator, Sequence from functools import lru_cache from operator import attrgetter from typing import Any, NamedTuple from urllib.request import Requ...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/openai/backend.py", "license": "GNU General Public License v3.0", "lines": 173, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/openai/config.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from functools import partial from qt.core import QCheckBox, QFormLayout, QLabel, QLineEdit, QWidget from calibre.ai.openai import OpenAI from calibre.ai.prefs import decode_secret, encode_secret, pref_for_provider, set_pre...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/openai/config.py", "license": "GNU General Public License v3.0", "lines": 71, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
kovidgoyal/calibre:src/calibre/ai/github/backend.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import datetime import json import os from collections.abc import Iterable, Iterator from functools import lru_cache from typing import Any, NamedTuple from urllib.request import Request from calibre.ai import AICapabilities...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/github/backend.py", "license": "GNU General Public License v3.0", "lines": 168, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/github/config.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from collections.abc import Sequence from functools import partial from qt.core import QFormLayout, QHBoxLayout, QLabel, QLineEdit, QWidget from calibre.ai.github import GitHubAI from calibre.ai.prefs import decode_secret, ...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/github/config.py", "license": "GNU General Public License v3.0", "lines": 92, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/google/backend.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> # Google studio account management: https://aistudio.google.com/usage # Docs: # Text generation: https://ai.google.dev/gemini-api/docs/text-generation#rest # Image generation with gemini: https://ai.google.dev/gemini-api/doc...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/google/backend.py", "license": "GNU General Public License v3.0", "lines": 335, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/google/config.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from functools import partial from qt.core import QCheckBox, QFormLayout, QLabel, QLineEdit, QWidget from calibre.ai.google import GoogleAI from calibre.ai.prefs import decode_secret, encode_secret, pref_for_provider, set_...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/google/config.py", "license": "GNU General Public License v3.0", "lines": 69, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
kovidgoyal/calibre:src/calibre/gui2/chat_widget.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from html import escape from math import ceil from typing import NamedTuple from qt.core import ( QFont, QFontInfo, QFrame, QHBoxLayout, QIcon, QPalette, QSize, QSizePolicy, Qt, QTextB...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/chat_widget.py", "license": "GNU General Public License v3.0", "lines": 203, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/utils.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import datetime import http import json import os import re import tempfile from collections.abc import Callable, Iterable, Iterator, Sequence from contextlib import suppress from enum import Enum, auto from functools import ...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/utils.py", "license": "GNU General Public License v3.0", "lines": 304, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/prefs.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from collections.abc import Iterator from copy import deepcopy from functools import lru_cache from typing import Any from calibre.ai import AICapabilities from calibre.customize import AIProviderPlugin from calibre.customiz...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/prefs.py", "license": "GNU General Public License v3.0", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
kovidgoyal/calibre:src/calibre/ai/config.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> from qt.core import QComboBox, QDialog, QGroupBox, QHBoxLayout, QLabel, QStackedLayout, QVBoxLayout, QWidget from calibre.ai import AICapabilities from calibre.ai.prefs import plugin_for_purpose, plugins_for_purpose, prefs f...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/config.py", "license": "GNU General Public License v3.0", "lines": 71, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
kovidgoyal/calibre:src/calibre/ai/open_router/config.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import datetime import textwrap from functools import partial from typing import TYPE_CHECKING, Any from qt.core import ( QAbstractItemView, QAbstractListModel, QCheckBox, QComboBox, QDialog, QDialogB...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/open_router/config.py", "license": "GNU General Public License v3.0", "lines": 414, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/ai/open_router/backend.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import datetime import json import os import re from collections.abc import Iterable, Iterator, Sequence from functools import lru_cache from typing import Any, NamedTuple from urllib.request import Request from calibre.ai i...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/ai/open_router/backend.py", "license": "GNU General Public License v3.0", "lines": 236, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/viewer/llm.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> and Amir Tehrani import string from collections.abc import Iterator from functools import lru_cache from typing import Any from qt.core import QDialog, QUrl, QVBoxLayout, QWidget, pyqtSignal from calibre.ai import ChatMessa...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/viewer/llm.py", "license": "GNU General Public License v3.0", "lines": 211, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/gui2/actions/column_tooltips.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2022, Charles Haley # from qt.core import QDialogButtonBox, Qt, QVBoxLayout from calibre.gui2 import error_dialog, safe_open_url from calibre.gui2.actions import InterfaceAction from calibre.gui2.dialogs.template_dialog import TemplateDialog from calibre.gui2.widgets2...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/gui2/actions/column_tooltips.py", "license": "GNU General Public License v3.0", "lines": 101, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/calibre:src/calibre/utils/tts/piper.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import atexit import json import os import sys from collections.abc import Callable from functools import partial from queue import Queue from threading import Lock, Thread from typing import Any, NamedTuple from calibre.con...
{ "repo_id": "kovidgoyal/calibre", "file_path": "src/calibre/utils/tts/piper.py", "license": "GNU General Public License v3.0", "lines": 197, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/kitty:kittens/command_palette/main.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net> import sys from functools import partial from typing import Any from kitty.fast_data_types import add_timer, get_boss from kitty.typing_compat import BossType from ..tui.handler import result_handler def collect_keys_dat...
{ "repo_id": "kovidgoyal/kitty", "file_path": "kittens/command_palette/main.py", "license": "GNU General Public License v3.0", "lines": 163, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/kitty:kitty_tests/command_palette.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net> from . import BaseTest class TestCommandPalette(BaseTest): def test_collect_keys_data(self): from kittens.command_palette.main import collect_keys_data from kitty.actions import groups opts = se...
{ "repo_id": "kovidgoyal/kitty", "file_path": "kitty_tests/command_palette.py", "license": "GNU General Public License v3.0", "lines": 130, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
kovidgoyal/kitty:kittens/choose_files/main.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import sys from typing import Any from kitty.conf.types import Definition from kitty.constants import appname from kitty.simple_cli_definitions import CONFIG_HELP, CompletionSpec from kitty.typing_compat import BossType fro...
{ "repo_id": "kovidgoyal/kitty", "file_path": "kittens/choose_files/main.py", "license": "GNU General Public License v3.0", "lines": 236, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
kovidgoyal/kitty:kittens/desktop_ui/main.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import sys from kitty.conf.types import Definition definition = Definition( '!kittens.choose_files', ) agr = definition.add_group egr = definition.end_group opt = definition.add_option map = definition.add_map mma = d...
{ "repo_id": "kovidgoyal/kitty", "file_path": "kittens/desktop_ui/main.py", "license": "GNU General Public License v3.0", "lines": 38, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
kovidgoyal/kitty:kitty_tests/panels.py
#!/usr/bin/env python # License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net> import shlex import subprocess def r(msg: str, cmdline: str) -> None: try: q = input('Test ' + msg + '? (y/n): ').lower() if q in ('y', 'yes'): try: subprocess.run(['kitten'] ...
{ "repo_id": "kovidgoyal/kitty", "file_path": "kitty_tests/panels.py", "license": "GNU General Public License v3.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
labmlai/annotated_deep_learning_paper_implementations:labml_nn/transformers/flash/test.py
""" ### Test Flash Attention Implementation This is the code to test and measure performance of our flash attention implementation """ import torch import triton from labml import logger, monit from labml_nn.transformers.flash import attention HI_PRES_TORCH = torch.float32 @torch.no_grad() def _calc_abs_rel_error...
{ "repo_id": "labmlai/annotated_deep_learning_paper_implementations", "file_path": "labml_nn/transformers/flash/test.py", "license": "MIT License", "lines": 148, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
labmlai/annotated_deep_learning_paper_implementations:labml_nn/helpers/datasets.py
import random from pathlib import PurePath, Path from typing import List, Callable, Dict, Optional from torchvision import datasets, transforms import torch from labml import lab from labml import monit from labml.configs import BaseConfigs from labml.configs import aggregate, option from labml.utils.download import ...
{ "repo_id": "labmlai/annotated_deep_learning_paper_implementations", "file_path": "labml_nn/helpers/datasets.py", "license": "MIT License", "lines": 242, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
labmlai/annotated_deep_learning_paper_implementations:labml_nn/helpers/device.py
import torch from labml.configs import BaseConfigs, hyperparams, option class DeviceInfo: def __init__(self, *, use_cuda: bool, cuda_device: int): self.use_cuda = use_cuda self.cuda_device = cuda_device self.cuda_count = torch.cuda.device_count() ...
{ "repo_id": "labmlai/annotated_deep_learning_paper_implementations", "file_path": "labml_nn/helpers/device.py", "license": "MIT License", "lines": 51, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
labmlai/annotated_deep_learning_paper_implementations:labml_nn/helpers/metrics.py
import dataclasses from abc import ABC import torch from labml import tracker class StateModule: def __init__(self): pass # def __call__(self): # raise NotImplementedError def create_state(self) -> any: raise NotImplementedError def set_state(self, data: any): raise...
{ "repo_id": "labmlai/annotated_deep_learning_paper_implementations", "file_path": "labml_nn/helpers/metrics.py", "license": "MIT License", "lines": 60, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
labmlai/annotated_deep_learning_paper_implementations:labml_nn/helpers/optimizer.py
from typing import Tuple import torch from labml import tracker from labml.configs import BaseConfigs, option, meta_config class OptimizerConfigs(BaseConfigs): r""" This creates a configurable optimizer. Arguments: learning_rate (float): Learning rate of the optimizer. Defaults to ``0.01``. ...
{ "repo_id": "labmlai/annotated_deep_learning_paper_implementations", "file_path": "labml_nn/helpers/optimizer.py", "license": "MIT License", "lines": 71, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
labmlai/annotated_deep_learning_paper_implementations:labml_nn/helpers/schedule.py
from typing import Tuple, List class Schedule: def __call__(self, x): raise NotImplementedError() class Flat(Schedule): def __init__(self, value): self.__value = value def __call__(self, x): return self.__value def __str__(self): return f"Schedule({self.__value})" ...
{ "repo_id": "labmlai/annotated_deep_learning_paper_implementations", "file_path": "labml_nn/helpers/schedule.py", "license": "MIT License", "lines": 60, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
labmlai/annotated_deep_learning_paper_implementations:labml_nn/helpers/trainer.py
import signal import typing from typing import Dict, List, Callable from typing import Optional, Tuple, Any, Collection import torch.optim import torch.optim import torch.utils.data import torch.utils.data from labml import tracker, logger, monit from labml.configs import BaseConfigs, meta_config, option from labml.in...
{ "repo_id": "labmlai/annotated_deep_learning_paper_implementations", "file_path": "labml_nn/helpers/trainer.py", "license": "MIT License", "lines": 402, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/core/tests/unit_tests/callbacks/test_handle_event.py
"""Tests for handle_event and _ahandle_event_for_handler fallback behavior. Covers the NotImplementedError fallback from on_chat_model_start to on_llm_start. Handlers must declare `serialized` and `messages` as explicit positional args (not *args) — see on_chat_model_start docstring for details. See: https://github.c...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/core/tests/unit_tests/callbacks/test_handle_event.py", "license": "MIT License", "lines": 98, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/anthropic/scripts/check_version.py
"""Check version consistency between `pyproject.toml` and `_version.py`. This script validates that the version defined in pyproject.toml matches the `__version__` variable in `langchain_anthropic/_version.py`. Intended for use as a pre-commit hook to prevent version mismatches. """ import re import sys from pathlib ...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/anthropic/scripts/check_version.py", "license": "MIT License", "lines": 47, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langchain:libs/partners/openrouter/langchain_openrouter/chat_models.py
"""OpenRouter chat models.""" from __future__ import annotations import json import warnings from collections.abc import AsyncIterator, Callable, Iterator, Mapping, Sequence from operator import itemgetter from typing import Any, Literal, cast from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun,...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openrouter/langchain_openrouter/chat_models.py", "license": "MIT License", "lines": 1174, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langchain-ai/langchain:libs/partners/openrouter/scripts/check_imports.py
"""Script to check imports of given Python files.""" import sys import traceback from importlib.machinery import SourceFileLoader if __name__ == "__main__": files = sys.argv[1:] has_failure = False for file in files: try: SourceFileLoader("x", file).load_module() except Excepti...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openrouter/scripts/check_imports.py", "license": "MIT License", "lines": 16, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langchain-ai/langchain:libs/partners/openrouter/tests/integration_tests/test_chat_models.py
"""Integration tests for `ChatOpenRouter` chat model.""" from __future__ import annotations import pytest from langchain_core.messages import AIMessageChunk, BaseMessageChunk from pydantic import BaseModel, Field from langchain_openrouter.chat_models import ChatOpenRouter def test_basic_invoke() -> None: """Te...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openrouter/tests/integration_tests/test_chat_models.py", "license": "MIT License", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/openrouter/tests/integration_tests/test_compile.py
"""Test compilation of integration tests.""" import pytest @pytest.mark.compile def test_placeholder() -> None: """Used for compiling integration tests without running any real tests."""
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openrouter/tests/integration_tests/test_compile.py", "license": "MIT License", "lines": 5, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langchain-ai/langchain:libs/partners/openrouter/tests/integration_tests/test_standard.py
"""Standard integration tests for `ChatOpenRouter`.""" from langchain_core.messages import AIMessage, AIMessageChunk from langchain_tests.integration_tests import ChatModelIntegrationTests from langchain_openrouter.chat_models import ChatOpenRouter MODEL_NAME = "openai/gpt-4o-mini" class TestChatOpenRouter(ChatMod...
{ "repo_id": "langchain-ai/langchain", "file_path": "libs/partners/openrouter/tests/integration_tests/test_standard.py", "license": "MIT License", "lines": 92, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test