def _sample_n(self, num_samples, seed=None, name=None):
if self.dimension < <NUM_LIT:0>:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>seed = seed_stream.SeedStream(seed, '<STR_LIT>')<EOL>with tf.name_scope('<STR_LIT>' or name):<EOL><INDENT>if not dtype_util.is_floating(self.concentration.dtype):<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT:{}>'.format(dtype_util.name(self.concentration.dtype)))<EOL><DEDENT>concentration = _replicate(num_samples, self.concentration)<EOL>concentration_shape = tf.shape(input=concentration)<EOL>if self.dimension <= <NUM_LIT:1>:<EOL><INDENT>shape = tf.concat([<EOL>concentration_shape, [self.dimension, self.dimension]], axis=<NUM_LIT:0>)<EOL>return tf.ones(shape=shape, dtype=self.concentration.dtype)<EOL><DEDENT>beta_conc = concentration + (self.dimension - <NUM_LIT>) / <NUM_LIT><EOL>beta_dist = beta.Beta(concentration1=beta_conc, concentration0=beta_conc)<EOL>corr12 = <NUM_LIT> * beta_dist.sample(seed=seed()) - <NUM_LIT:1.><EOL>first_row = tf.concat([<EOL>tf.ones_like(corr12)[..., tf.newaxis],<EOL>tf.zeros_like(corr12)[..., tf.newaxis]], axis=-<NUM_LIT:1>)<EOL>second_row = tf.concat([<EOL>corr12[..., tf.newaxis],<EOL>tf.sqrt(<NUM_LIT:1> - corr12**<NUM_LIT:2>)[..., tf.newaxis]], axis=-<NUM_LIT:1>)<EOL>chol_result = tf.concat([<EOL>first_row[..., tf.newaxis, :],<EOL>second_row[..., tf.newaxis, :]], axis=-<NUM_LIT:2>)<EOL>for n in range(<NUM_LIT:2>, self.dimension):<EOL><INDENT>beta_conc -= <NUM_LIT:0.5><EOL>norm = beta.Beta(<EOL>concentration1=n/<NUM_LIT>,<EOL>concentration0=beta_conc<EOL>).sample(seed=seed())<EOL>distance = tf.sqrt(norm)[..., tf.newaxis]<EOL>direction = _uniform_unit_norm(<EOL>n, concentration_shape, self.concentration.dtype, seed)<EOL>raw_correlation = distance * direction  <EOL>new_row = tf.concat(<EOL>[raw_correlation, tf.sqrt(<NUM_LIT:1.> - norm[..., tf.newaxis])], axis=-<NUM_LIT:1>)<EOL>chol_result = tf.concat([<EOL>chol_result,<EOL>tf.zeros_like(chol_result[..., <NUM_LIT:0>][..., tf.newaxis])], axis=-<NUM_LIT:1>)<EOL>chol_result = tf.concat(<EOL>[chol_result, new_row[..., tf.newaxis, :]], axis=-<NUM_LIT:2>)<EOL><DEDENT>if self.input_output_cholesky:<EOL><INDENT>return chol_result<EOL><DEDENT>result = tf.matmul(chol_result, chol_result, transpose_b=True)<EOL>result = tf.linalg.set_diag(<EOL>result,<EOL>tf.ones(shape=tf.shape(input=result)[:-<NUM_LIT:1>], dtype=result.dtype))<EOL>return result<EOL><DEDENT>
Returns a Tensor of samples from an LKJ distribution.

        Args:
          num_samples: Python `int`. The number of samples to draw.
          seed: Python integer seed for RNG
          name: Python `str` name prefixed to Ops created by this function.

        Returns:
          samples: A Tensor of correlation matrices with shape `[n, B, D, D]`,
            where `B` is the shape of the `concentration` parameter, and `D`
            is the `dimension`.

        Raises:
          ValueError: If `dimension` is negative.