code: def test_evaluate_spherical_harmonics_preset(self):
      tensor_size = np.random.randint(3)
      tensor_shape = np.random.randint(
          1, 10, size=(tensor_size)
      ).tolist()
      pt_3d = tf.convert_to_tensor(
          value=np.random.uniform(size=tensor_shape + [3])
      )
      pt_3d = tf.math.l2_normalize(pt_3d, axis=-1)
      x, y, z = tf.unstack(pt_3d, axis=-1)
      x = tf.expand_dims(x, axis=-1)
      y = tf.expand_dims(y, axis=-1)
      z = tf.expand_dims(z, axis=-1)
      pt_spherical = math_helpers.cartesian_to_spherical_coordinates(
          pt_3d
      )
      _, theta, phi = tf.unstack(pt_spherical, axis=-1)
      theta = tf.expand_dims(theta, axis=-1)
      phi = tf.expand_dims(phi, axis=-1)
      ones = tf.ones_like(z)
  
      with self.subTest(name="l_0_m_0"):
          l = tf.zeros_like(theta, dtype=tf.int32)
          m = tf.zeros_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = ones / (2.0 * tf.sqrt(ones * np.pi))
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_1_m_-1"):
          l = tf.ones_like(theta, dtype=tf.int32)
          m = -tf.ones_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = -tf.sqrt(3.0 * ones) * y / (2.0 * tf.sqrt(ones * np.pi))
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_1_m_0"):
          l = tf.ones_like(theta, dtype=tf.int32)
          m = tf.zeros_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = (tf.sqrt(3.0 * ones) * z) / (2.0 * tf.sqrt(ones * np.pi))
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_1_m_1"):
          l = tf.ones_like(theta, dtype=tf.int32)
          m = tf.ones_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = -tf.sqrt(3.0 * ones) * x / (2.0 * tf.sqrt(ones * np.pi))
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_2_m-2"):
          l = 2 * tf.ones_like(theta, dtype=tf.int32)
          m = -2 * tf.ones_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = (
              tf.sqrt(15.0 * ones)
              * y
              * x
              / (2.0 * tf.sqrt(ones * np.pi))
          )
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_2_m_-1"):
          l = 2 * tf.ones_like(theta, dtype=tf.int32)
          m = -tf.ones_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = (
              -tf.sqrt(15.0 * ones)
              * y
              * z
              / (2.0 * tf.sqrt(ones * np.pi))
          )
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_2_m_0"):
          l = 2 * tf.ones_like(theta, dtype=tf.int32)
          m = tf.zeros_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = (
              tf.sqrt(5.0 * ones)
              * (3.0 * z * z - ones)
              / (4.0 * tf.sqrt(ones * np.pi))
          )
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_2_m_1"):
          l = 2 * tf.ones_like(theta, dtype=tf.int32)
          m = tf.ones_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = (
              -tf.sqrt(15.0 * ones)
              * x
              * z
              / (2.0 * tf.sqrt(ones * np.pi))
          )
  
          self.assertAllClose(val, gt)
  
      with self.subTest(name="l_2_m_2"):
          l = 2 * tf.ones_like(theta, dtype=tf.int32)
          m = 2 * tf.ones_like(theta, dtype=tf.int32)
          val = spherical_harmonics.evaluate_spherical_harmonics(
              l, m, theta, phi
          )
          gt = (
              tf.sqrt(15.0 * ones)
              * (x * x - y * y)
              / (4.0 * tf.sqrt(ones * np.pi))
          )
  
          self.assertAllClose(val, gt)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_graphics.math import math_helpers
  from tensorflow_graphics.math import spherical_harmonics
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import test_case
label_desc: Use image node_id 18 for calling the SphericalHarmonicsTest obj's underlying member method code with example usage: obj.test_evaluate_spherical_harmonics_preset() without return types