code: def mean(values, ignore_nan=False, empty=0):
      """Nanmean compatible with generators."""
      values = iter(values)
      if ignore_nan:
          values = ifilterfalse(isnan, values)
      try:
          n = 1
          acc = next(values)
      except StopIteration:
          if empty == "raise":
              raise ValueError("Empty mean")
          return empty
      for n, v in enumerate(values, 2):
          acc += v
      if n == 1:
          return acc
      return acc / n
  
imports: from __future__ import print_function, division
  from typing import Optional, Union
  import torch
  import torch.nn.functional
  from torch.autograd import Variable
  from torch.nn.modules.loss import _Loss
label_desc: Use image node_id 9 for calling a global function with example usage: mean(values, ignore_nan, empty) and returns: unknown, acc, empty