code: def _FlatInnerDims(tensor, ndims=2):
      shape = list(tensor.shape)
      return tensor.reshape(
          [functools.reduce(lambda x, y: x * y, shape[: -ndims + 1], 1)]
          + shape[-ndims + 1 :]
      )
  
file_path: tensorflow-upstream/tensorflow/python/kernel_tests/v1_compat_tests/scatter_nd_ops_test.py
imports: import functools
  import numpy
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import state_ops
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling a global function with example usage: _FlatInnerDims(tensor, ndims) and returns: tensor