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 :]
      )
  
imports: import functools
  import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  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