code: def spherical_to_cartesian_coordinates(
      point_spherical: TensorLike,
      name: str = "spherical_to_cartesian_coordinates",
  ) -> TensorLike:
      """Function to transform Cartesian coordinates to spherical coordinates.
  
      Note:
        In the following, A1 to An are optional batch dimensions.
  
      Args:
        point_spherical: A tensor of shape `[A1, ..., An, 3]`. The last dimension
          contains r, theta, and phi that respectively correspond to the radius,
          polar angle and azimuthal angle; r must be non-negative.
        name: A name for this op. Defaults to "spherical_to_cartesian_coordinates".
  
      Raises:
        tf.errors.InvalidArgumentError: If r, theta or phi contains out of range
        data.
  
      Returns:
        A tensor of shape `[A1, ..., An, 3]`, where the last dimension contains the
        cartesian coordinates in x,y,z order.
      """
      with tf.name_scope(name):
          point_spherical = tf.convert_to_tensor(value=point_spherical)
  
          shape.check_static(
              tensor=point_spherical,
              tensor_name="point_spherical",
              has_dim_equals=(-1, 3),
          )
  
          r, theta, phi = tf.unstack(point_spherical, axis=-1)
          r = asserts.assert_all_above(r, 0)
          tmp = r * tf.sin(theta)
          x = tmp * tf.cos(phi)
          y = tmp * tf.sin(phi)
          z = r * tf.cos(theta)
          return tf.stack((x, y, z), axis=-1)
  
file_path: graphics/tensorflow_graphics/math/math_helpers.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import export_api
  from tensorflow_graphics.util import safe_ops
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util.type_alias import Float
  from tensorflow_graphics.util.type_alias import TensorLike
label_desc: Use image node_id 6 for calling a global function with example usage: spherical_to_cartesian_coordinates(point_spherical, name) and returns: tf