# tensorplay.distributions.register_kl Source: https://www.tensorplay.cn/docs/generated/tensorplay.distributions.register_kl.html ```python tensorplay.distributions.register_kl(type_p, type_q) ``` Decorator to register a pairwise function with [kl_divergence()](/docs/generated/tensorplay.distributions.kl_divergence.html#tensorplay.distributions.kl_divergence). Usage: ``` @register_kl(Normal, Normal) def kl_normal_normal(p, q): # insert implementation here ``` Lookup returns the most specific (type,type) match ordered by subclass. If the match is ambiguous, a RuntimeWarning is raised. For example to resolve the ambiguous situation: ``` @register_kl(BaseP, DerivedQ) def kl_version1(p, q): ... @register_kl(DerivedP, BaseQ) def kl_version2(p, q): ... ``` you should register a third most-specific implementation, e.g.: ``` register_kl(DerivedP, DerivedQ)(kl_version1) # Break the tie. ``` Parameters: - type_p ([type](https://docs.python.org/3/builtins/functions.html#type)) – A subclass of [Distribution](/docs/generated/tensorplay.distributions.Distribution.html#tensorplay.distributions.Distribution). - type_q ([type](https://docs.python.org/3/builtins/functions.html#type)) – A subclass of [Distribution](/docs/generated/tensorplay.distributions.Distribution.html#tensorplay.distributions.Distribution).