class_docstr: Test cases for segment reduction ops.
class_docstr_tok: ["Test","cases","for","segment","reduction","ops","."]
code: def _segmentReduction(self, op, data, indices, num_segments):
      with self.session() as sess, self.test_scope():
          d = array_ops.placeholder(data.dtype, shape=data.shape)
          if isinstance(indices, int):
              i = array_ops.placeholder(np.int32, shape=[])
          else:
              i = array_ops.placeholder(
                  indices.dtype, shape=indices.shape
              )
          return sess.run(op(d, i, num_segments), {d: data, i: indices})
  
imports: import functools
  import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.client import device_lib
  from tensorflow.python.framework import dtypes
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 2 for calling the SegmentReductionOpsTest obj's underlying member method code with example usage: obj._segmentReduction(op, data, indices, num_segments) and returns: sess