code: def test_cut_or_padding(self):
      # test for 1d
      origin_1_t = tf.placeholder(dtype=tf.int32, shape=[None])
      after_1_t = cut_or_padding(origin_1_t, 3)
  
      with self.cached_session(use_gpu=False, force_gpu=False) as sess:
          # test for padding
          res = sess.run(after_1_t, feed_dict={origin_1_t: [1, 2]})
          self.assertAllEqual(res, [1, 2, 0])
  
          # test for cut
          res = sess.run(
              after_1_t, feed_dict={origin_1_t: [1, 2, 3, 4, 5]}
          )
          self.assertAllEqual(res, [1, 2, 3])
  
      # test for 2d
      origin_2_t = tf.placeholder(dtype=tf.int32, shape=[None, None])
      after_2_t = cut_or_padding(origin_2_t, 3)
      with self.cached_session(use_gpu=False, force_gpu=False) as sess:
          # test for padding
          res = sess.run(
              after_2_t, feed_dict={origin_2_t: [[1, 2], [1, 2]]}
          )
          self.assertAllEqual(res, [[1, 2, 0], [1, 2, 0]])
  
          # test for cut
          res = sess.run(
              after_2_t,
              feed_dict={origin_2_t: [[1, 2, 3, 4], [1, 2, 3, 4]]},
          )
          self.assertAllEqual(res, [[1, 2, 3], [1, 2, 3]])
  
file_path: delta/delta/layers/utils_test.py
imports: from absl import logging
  import delta.compat
  from delta.layers import utils
  from delta.layers.utils import cut_or_padding
  from delta.layers.utils import compute_sen_lens
  from delta.layers.utils import compute_doc_lens
  from delta.layers.utils import split_one_doc_to_true_len_sens
label_desc: Use image node_id 4 for calling the LayerUtilsTest obj's underlying member method code with example usage: obj.test_cut_or_padding() without return types