code: def _shrink_longest_allocation(segment_lengths, max_row_length):
      """Allocating quota via a shrink-longest strategy."""
      depth = array_ops.shape(segment_lengths)[-1]
  
      def _condition(l):
          return math_ops.reduce_any(
              math_ops.greater(
                  math_ops.reduce_sum(l, axis=-1), max_row_length
              )
          )
  
      def _body(l):
          needs_truncation = math_ops.cast(
              math_ops.greater(
                  math_ops.reduce_sum(l, axis=-1), max_row_length
              ),
              dtypes.int32,
          )
          minus_ones_or_zeros = array_ops.expand_dims(
              -1 * needs_truncation, axis=1
          )
          one_hot_to_max_position = array_ops.one_hot(
              math_ops.argmax(l, axis=-1),
              depth=depth,
              dtype=dtypes.int32,
          )
          return (l + minus_ones_or_zeros * one_hot_to_max_position,)
  
      return while_loop.while_loop_v2(
          cond=_condition, body=_body, loop_vars=[segment_lengths]
      )
  
imports: import abc
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.ragged import ragged_array_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow_text.python.ops import item_selector_ops
  from tensorflow.python.framework import load_library
  from tensorflow.python.platform import resource_loader
  from tensorflow.python.ops import while_loop
label_desc: Use image node_id 3 for calling a global function with example usage: _shrink_longest_allocation(segment_lengths, max_row_length) and returns: while_loop, math_ops, unknown