<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/probability/blob/v0.25.0/tensorflow_probability/python/distributions/kullback_leibler.py#L149-L192) |

Decorator to register a KL divergence implementation function.

#### View aliases


**Main aliases**

[`tfp.layers.dense_variational_v2.kullback_leibler.RegisterKL`](https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/RegisterKL)

<br />

    tfp.distributions.RegisterKL(
        dist_cls_a, dist_cls_b
    )

#### Usage:

    @distributions.RegisterKL(distributions.Normal, distributions.Normal)
    def _kl_normal_mvn(norm_a, norm_b):
      # Return KL(norm_a || norm_b)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `dist_cls_a` | the class of the first argument of the KL divergence. |
| `dist_cls_b` | the class of the second argument of the KL divergence. |

<br />

## Methods

### `__call__`

[View source](https://github.com/tensorflow/probability/blob/v0.25.0/tensorflow_probability/python/distributions/kullback_leibler.py#L171-L192)

    __call__(
        kl_fn
    )

Perform the KL registration.

<br />

<br />

<br />

| Args ||
|---|---|
| `kl_fn` | The function to use for the KL divergence. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| kl_fn ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `TypeError` | if kl_fn is not a callable. |
| `ValueError` | if a KL divergence function has already been registered for the given argument classes. |

<br />