code: def _log_prob_sum(trace: Trace, batch_size: int) -> torch.Tensor:
      """Computes vectorized log_prob_sum batched over the leftmost dimension."""
      trace.compute_log_prob()
      result = 0.0
      for site in trace.nodes.values():
          if site["type"] == "sample":
              logp = site["log_prob"]
              assert logp.shape[:1] == (batch_size,)
              result += logp.reshape(batch_size, -1).sum(-1)
      return result
  
file_path: pyro/pyro/infer/resampler.py
imports: from typing import Callable, Dict, Optional
  import torch
  import pyro
  import pyro.poutine
  from pyro.poutine.trace_struct import Trace
  from pyro.poutine.util import site_is_subsample
label_desc: Use image node_id 1 for calling a global function with example usage: _log_prob_sum(trace, batch_size) and returns: result