code: def _weighted_mean(input, log_weights, dim=0, keepdim=False):
      dim = input.dim() + dim if dim < 0 else dim
      log_weights = log_weights.reshape(
          [-1] + (input.dim() - dim - 1) * [1]
      )
      max_log_weight = log_weights.max(dim=0)[0]
      relative_probs = (log_weights - max_log_weight).exp()
      return (input * relative_probs).sum(
          dim=dim, keepdim=keepdim
      ) / relative_probs.sum()
  
imports: import math
  import numbers
  import torch
  from torch.fft import irfft, rfft
  from .tensor_utils import next_fast_len
label_desc: Use image node_id 12 for calling a global function with example usage: _weighted_mean(input, log_weights, dim, keepdim) and returns: unknown