<commit_before># Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Tests TFP distribution compositionality with JAX transformations."""
import functools
import os

from absl import flags
from absl.testing import parameterized
import hypothesis as hp
from hypothesis import strategies as hps
import jax
from jax import random
from jax.config import config
import jax.numpy as np

# pylint: disable=no-name-in-module

from tensorflow_probability.python.internal import reparameterization
from tensorflow_probability.python.internal.backend import jax as tf
from tensorflow_probability.substrates.jax.distributions import hypothesis_testlib as dhps
from tensorflow_probability.substrates.jax.internal import hypothesis_testlib as tfp_hps
from tensorflow_probability.substrates.jax.internal import test_util

flags.DEFINE_bool('execute_only', False,
                  'If specified, skip equality checks and only verify '
                  'execution of transforms works.')
# Allows us to easily evaluate which blocklisted items now pass.
flags.DEFINE_bool('blocklists_only', False,
                  'If specified, run tests only for blocklisted distributions.')
FLAGS = flags.FLAGS

JIT_SAMPLE_BLOCKLIST = (
    'Bates',
    'Independent',  # http://b/164415821
    'Multinomial',
    'Skellam',  # http://b/171079052
    'VonMisesFisher',  # http://b/171079052
)
JIT_LOGPROB_BLOCKLIST = (
    'BatchReshape',  # http://b/161984806
    'Bates',
    'Independent',  # http://b/164415821
    'MixtureSameFamily',  # http://b/164415821
    'Skellam',  # http://b/171079052
    'VonMisesFisher',  # http://b/171079052
)

VMAP_SAMPLE_BLOCKLIST = (
    'NegativeBinomial',  # http://b/170871051
    'BatchReshape',  # Too slow: http://b/170871051
)
VMAP_LOGPROB_BLOCKLIST = (
    'BatchReshape',  # http://b/161984806
    'Bates',
    'NegativeBinomial',  # Times out.
    'QuantizedDistribution',  # http://b/162940364
)

PMAP_SAMPLE_BLOCKLIST = (
    'Bates',
    'BatchReshape',  # http://b/163171224
)<commit_msg>Suppress Jax JitTest.testLogProbNegativeBinomial for unexplained slowness.<commit_after># Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Tests TFP distribution compositionality with JAX transformations."""
import functools
import os

from absl import flags
from absl.testing import parameterized
import hypothesis as hp
from hypothesis import strategies as hps
import jax
from jax import random
from jax.config import config
import jax.numpy as np

# pylint: disable=no-name-in-module

from tensorflow_probability.python.internal import reparameterization
from tensorflow_probability.python.internal.backend import jax as tf
from tensorflow_probability.substrates.jax.distributions import hypothesis_testlib as dhps
from tensorflow_probability.substrates.jax.internal import hypothesis_testlib as tfp_hps
from tensorflow_probability.substrates.jax.internal import test_util

flags.DEFINE_bool('execute_only', False,
                  'If specified, skip equality checks and only verify '
                  'execution of transforms works.')
# Allows us to easily evaluate which blocklisted items now pass.
flags.DEFINE_bool('blocklists_only', False,
                  'If specified, run tests only for blocklisted distributions.')
FLAGS = flags.FLAGS

JIT_SAMPLE_BLOCKLIST = (
    'Bates',
    'Independent',  # http://b/164415821
    'Multinomial',
    'Skellam',  # http://b/171079052
    'VonMisesFisher',  # http://b/171079052
)
JIT_LOGPROB_BLOCKLIST = (
    'BatchReshape',  # http://b/161984806
    'Bates',
    'Independent',  # http://b/164415821
    'MixtureSameFamily',  # http://b/164415821
    'NegativeBinomial',  # http://b/170871051
    'Skellam',  # http://b/171079052
    'VonMisesFisher',  # http://b/171079052
)

VMAP_SAMPLE_BLOCKLIST = (
    'NegativeBinomial',  # http://b/170871051
    'BatchReshape',  # Too slow: http://b/170871051
)
VMAP_LOGPROB_BLOCKLIST = (
    'BatchReshape',  # http://b/161984806
    'Bates',
    'NegativeBinomial',  # Times out.
    'QuantizedDistribution',  # http://b/162940364
)

PMAP_SAMPLE_BLOCKLIST = (
    'Bates',
    'BatchReshape',  # http://b/163171224
)
{'fraction_non_alphanumeric': 0.11926435073379156, 'fraction_numerical': 0.04811443433029909, 'mean_word_length': 4.142311365807068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '376715', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1582, 'n_words': 473}