def _unsorted_segment_N(data, segment_ids, num_segments):
    ' Helper function for unsorted_segment_mean/_sqrtN. Computes the number\n      of segment entries with 0-entries set to 1 to allow division by N.\n  '
    segment_ids_shape = array_ops.shape_internal(segment_ids)
    ones_tensor = array_ops.ones(segment_ids_shape, dtype=data.dtype)
    N = gen_math_ops.unsorted_segment_sum(ones_tensor, segment_ids, num_segments)
    ndims_output = (data.shape.ndims - segment_ids.shape.ndims)
    broadcast_shape = ([num_segments] + ([1] * ndims_output))
    N = array_ops.reshape(N, broadcast_shape)
    return gen_math_ops.maximum(N, 1)
Helper function for unsorted_segment_mean/_sqrtN. Computes the number
of segment entries with 0-entries set to 1 to allow division by N.
def _unsorted_segment_N(data, segment_ids, num_segments):
    ' Helper function for unsorted_segment_mean/_sqrtN. Computes the number\n      of segment entries with 0-entries set to 1 to allow division by N.\n  '
    segment_ids_shape = array_ops.shape_internal(segment_ids)
    ones_tensor = array_ops.ones(segment_ids_shape, dtype=data.dtype)
    N = gen_math_ops.unsorted_segment_sum(ones_tensor, segment_ids, num_segments)
    ndims_output = (data.shape.ndims - segment_ids.shape.ndims)
    broadcast_shape = ([num_segments] + ([1] * ndims_output))
    N = array_ops.reshape(N, broadcast_shape)
    return gen_math_ops.maximum(N, 1)