code: def _make_tensor_slice_spec(slice_spec, use_constant=True):
      """Wraps all integers in an extended slice spec w/ a tensor.
  
      This function is used to help test slicing when the slice spec contains
      tensors, rather than integers.
  
      Args:
        slice_spec: The extended slice spec.
        use_constant: If true, then wrap each integer with a tf.constant.  If false,
          then wrap each integer with a tf.placeholder.
  
      Returns:
        A copy of slice_spec, but with each integer i replaced with tf.constant(i).
      """
  
      def make_piece_scalar(piece):
          if isinstance(piece, int):
              scalar = constant_op.constant(piece)
              if use_constant:
                  return scalar
              else:
                  return array_ops.placeholder_with_default(scalar, [])
          elif isinstance(piece, slice):
              return slice(
                  make_piece_scalar(piece.start),
                  make_piece_scalar(piece.stop),
                  make_piece_scalar(piece.step),
              )
          else:
              return piece
  
      if isinstance(slice_spec, tuple):
          return tuple(make_piece_scalar(piece) for piece in slice_spec)
      else:
          return make_piece_scalar(slice_spec)
  
imports: import re
  from absl.testing import parameterized
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import tensor_getitem_override
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged.ragged_tensor import RaggedTensor
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 1 for calling a global function with example usage: _make_tensor_slice_spec(slice_spec, use_constant) and returns: tuple, make_piece_scalar, scalar, array_ops, slice, piece