code: def _make_flatteners(self, old_shape, axis):
      axis = np.array(axis).reshape(-1)
      old_shape = np.array(old_shape).reshape(-1)
      rank = len(old_shape)
      axis = np.where(axis < 0, axis + rank, axis)
      other_axis = np.setdiff1d(range(rank), axis)
      new_shape = np.concatenate([[-1], old_shape[other_axis]], axis=0)
      new_perm = np.concatenate([axis, other_axis], axis=0)
  
      def _flatten(x):
          return np.reshape(np.transpose(x, new_perm), new_shape)
  
      undo_permutation = np.argsort(new_perm)
      permuted_shape = np.concatenate(
          [old_shape[axis], old_shape[other_axis]], axis=0
      )
  
      def _unflatten(x):
          return np.transpose(
              np.reshape(x, permuted_shape), undo_permutation
          )
  
      return _flatten, _unflatten
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.stats import leave_one_out
label_desc: Use image node_id 1 for calling the LogSooMeanTest obj's underlying member method code with example usage: obj._make_flatteners(old_shape, axis) and returns: _flatten,  _unflatten, np, np