code: def vector_size_to_square_matrix_size(d, validate_args, name=None):
      """Convert a vector size to a matrix size."""
      if isinstance(d, (float, int, np.generic, np.ndarray)):
          n = (-1 + np.sqrt(1 + 8 * d)) / 2.0
          if float(int(n)) != n:
              raise ValueError(
                  "Vector length {} is not a triangular number.".format(
                      d
                  )
              )
          return int(n)
      else:
          with tf.name_scope(
              name or "vector_size_to_square_matrix_size"
          ) as name:
              n = (
                  -1.0 + tf.sqrt(1 + 8.0 * tf.cast(d, dtype=tf.float32))
              ) / 2.0
              if validate_args:
                  with tf.control_dependencies(
                      [
                          tf.debugging.Assert(
                              tf.math.equal(
                                  tf.cast(
                                      tf.cast(n, dtype=tf.int32),
                                      dtype=tf.float32,
                                  ),
                                  n,
                              ),
                              data=[
                                  "Vector length is not a triangular number: ",
                                  d,
                              ],
                          )
                      ]
                  ):
                      n = tf.identity(n)
              return tf.cast(n, d.dtype)
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math.linalg import fill_triangular
  from tensorflow_probability.python.math.linalg import fill_triangular_inverse
label_desc: Use image node_id 1 for calling a global function with example usage: vector_size_to_square_matrix_size(d, validate_args, name) and returns: int, tf