code: def __flatten_index(pos, shape):
      """
      Takes a three dimensional index (x,y,z) and computes the index required to access the
      same element in the flattened version of the array.
      """
      res = 0
      acc = 1
      for pi, si in zip(reversed(pos), reversed(shape)):
          res += pi * acc
          acc *= si
      return res
  
file_path: medpy/medpy/graphcut/energy_voxel.py
imports: import sys
  import numpy
  import scipy
  import math
label_desc: Use image node_id 13 for calling a global function with example usage: __flatten_index(pos, shape) and returns: res