code: def masked_mean(x, mask, dim=-1, keepdim=True):
      """Masked  Mean
  
      Compute the mean of tensor `x` along dimension, ignoring values where
      `mask` is False. `x` and `mask` need to be broadcastable.
  
      **Parameters:**<br>
      `x`: torch.Tensor to compute mean of along `dim` dimension.<br>
      `mask`: torch Tensor bool with same shape as `x`, where `x` is valid and False
              where `x` should be masked. Mask should not be all False in any column of
              dimension dim to avoid NaNs from zero division.<br>
      `dim` (int, optional): Dimension to take mean of. Defaults to -1.<br>
      `keepdim` (bool, optional): Keep dimension of `x` or not. Defaults to True.<br>
  
      **Returns:**<br>
      `x_mean`: torch.Tensor with normalized values.
      """
      x_nan = x.float().masked_fill(mask < 1, float("nan"))
      x_mean = x_nan.nanmean(dim=dim, keepdim=keepdim)
      x_mean = torch.nan_to_num(x_mean, nan=0.0)
      return x_mean
  
imports: import torch
  import torch.nn
label_desc: Use image node_id 2 for calling a global function with example usage: masked_mean(x, mask, dim, keepdim) and returns: x_mean