code: def _calc_mean(x, groups):
      axis = (0,) + tuple(range(2, x.ndim))
      return x.mean(axis=axis).reshape(groups, -1)
  
imports: import contextlib
  import os
  import tempfile
  import unittest
  import numpy
  import chainer
  from chainer import links
  from chainer import testing
label_desc: Use image node_id 5 for calling a global function with example usage: _calc_mean(x, groups) and returns: x