def _sample_3d(self, n, seed=None):
seed = seed_stream.SeedStream(seed, salt='<STR_LIT>')<EOL>u_shape = tf.concat([[n], self._batch_shape_tensor()], axis=<NUM_LIT:0>)<EOL>z = tf.random.uniform(u_shape, seed=seed(), dtype=self.dtype)<EOL>safe_conc = tf.where(self.concentration > <NUM_LIT:0>,<EOL>self.concentration,<EOL>tf.ones_like(self.concentration))<EOL>safe_z = tf.where(z > <NUM_LIT:0>, z, tf.ones_like(z))<EOL>safe_u = <NUM_LIT:1> + tf.reduce_logsumexp(<EOL>input_tensor=[<EOL>tf.math.log(safe_z),<EOL>tf.math.log1p(-safe_z) - <NUM_LIT:2> * safe_conc<EOL>],<EOL>axis=<NUM_LIT:0>) / safe_conc<EOL>u = tf.where(self.concentration > tf.zeros_like(safe_u), safe_u,<EOL><NUM_LIT:2> * z - <NUM_LIT:1>)<EOL>u = tf.where(tf.equal(z, <NUM_LIT:0>), -tf.ones_like(u), u)<EOL>if not self._allow_nan_stats:<EOL><INDENT>u = tf.debugging.check_numerics(u, '<STR_LIT>')<EOL><DEDENT>return u[..., tf.newaxis]<EOL>
Specialized inversion sampler for 3D.