code: def testLaplacian1D(self):
      action_spec = tensor_spec.BoundedTensorSpec(
          dtype=tf.int32, shape=(), minimum=0, maximum=4
      )
      laplacian_matrix = tf.convert_to_tensor(
          utils.build_laplacian_over_ordinal_integer_actions(
              action_spec
          ),
          dtype=tf.float32,
      )
      res = tf.matmul(
          laplacian_matrix, tf.ones([5, 1], dtype=tf.float32)
      )
      # The vector of ones is in the null space of the Laplacian matrix.
      self.assertAllClose(0.0, self.evaluate(tf.norm(res)))
  
      # The row sum is zero.
      row_sum = tf.reduce_sum(laplacian_matrix, 1)
      self.assertAllClose(0.0, self.evaluate(tf.norm(row_sum)))
  
      # The column sum is zero.
      column_sum = tf.reduce_sum(laplacian_matrix, 0)
      self.assertAllClose(0.0, self.evaluate(tf.norm(column_sum)))
  
      # The diagonal elements are 2.0.
      self.assertAllClose(2.0, laplacian_matrix[1, 1])
  
      laplacian_matrix_expected = np.array(
          [
              [1.0, -1.0, 0.0, 0.0, 0.0],
              [-1.0, 2.0, -1.0, 0.0, 0.0],
              [0.0, -1.0, 2.0, -1.0, 0.0],
              [0.0, 0.0, -1.0, 2.0, -1.0],
              [0.0, 0.0, 0.0, -1.0, 1.0],
          ]
      )
      self.assertAllClose(
          laplacian_matrix_expected, self.evaluate(laplacian_matrix)
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.bandits.agents import utils
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
label_desc: Use image node_id 3 for calling the UtilsTest obj's underlying member method code with example usage: obj.testLaplacian1D() without return types