 class="ident">log_sum_exp_trick</span></span>(<span>x, log_w=None, dim=-1, keepdim=False)</span>
</code></dt>
<dd>
<div class="desc"><p>Compute log(sum(w * exp(x), dim=dim, keepdim=keepdim)) safely.</p>
<p>Uses the logsumexp trick for the computation of this quantity.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def log_sum_exp_trick(x, log_w=None, dim=-1, keepdim=False):
    &#34;&#34;&#34;Compute log(sum(w * exp(x), dim=dim, keepdim=kee