class_docstr: Tangent space of M for Simplex distributions in R^n.
class_docstr_tok: ["Tangent","space","of","M","for","Simplex","distributions","in","R^n","."]
code: def _transform_coordinatewise(self, x, f, **kwargs):
      # Compute the diagonal. New matrix is Linop that we can easily write.
      dim = ps.shape(x)[-1]
      diag_jacobian = spaces.coordinatewise_jvp(f, x)
      # Multiplying the basis written in block form as [I, 1] by the diagonal
      # results in this operator:
      block1 = tf.linalg.LinearOperatorDiag(diag_jacobian[..., :-1])
      block2 = tf.linalg.LinearOperatorFullMatrix(
          diag_jacobian[..., -1:, tf.newaxis]
          * tf.ones([dim - 1, 1], dtype=x.dtype)
      )
      linop = lorb.LinearOperatorRowBlock([block1, block2])
  
      # The volume can be calculated again by the matrix determinant lemma:
      # det(D**2 + d_n**2 11^T) = (1 + d_n**2 1(D^-1)**21^T) * det(D**2)
      # = (\sum d_i**-2) * \prod d_i**2
      log_diag_jacobian = tf.math.log(tf.math.abs(diag_jacobian))
      log_volume = tf.math.reduce_sum(log_diag_jacobian, axis=-1)
      log_volume = (
          log_volume
          + 0.5
          * tf.math.reduce_logsumexp(-2.0 * log_diag_jacobian, axis=-1)
          - 0.5 * np.log(dim)
      )
      return log_volume, spaces.GeneralSpace(
          spaces.LinearOperatorBasis(linop),
          computed_log_volume=log_volume,
      )
  
file_path: probability/tensorflow_probability/python/experimental/tangent_spaces/simplex.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.linalg import linear_operator_row_block
  from tensorflow_probability.python.experimental.tangent_spaces import spaces
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 3 for calling the ProbabilitySimplexSpace obj's underlying member method code with example usage: obj._transform_coordinatewise(x, f) and returns: log_volume,  spaces