def sample_dynamic_prior(self, samples, batch_size, length, fixed=False):
if fixed:<EOL><INDENT>sample_batch_size = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>sample_batch_size = batch_size<EOL><DEDENT>sample, state = self.dynamic_prior.zero_state([samples, sample_batch_size])<EOL>locs = []<EOL>scale_diags = []<EOL>sample_list = []<EOL>for _ in range(length):<EOL><INDENT>dist, state = self.dynamic_prior(sample, state)<EOL>sample = dist.sample()<EOL>locs.append(dist.parameters["<STR_LIT>"])<EOL>scale_diags.append(dist.parameters["<STR_LIT>"])<EOL>sample_list.append(sample)<EOL><DEDENT>sample = tf.stack(sample_list, axis=<NUM_LIT:2>)<EOL>loc = tf.stack(locs, axis=<NUM_LIT:2>)<EOL>scale_diag = tf.stack(scale_diags, axis=<NUM_LIT:2>)<EOL>if fixed:  <EOL><INDENT>sample = sample + tf.zeros([batch_size, <NUM_LIT:1>, <NUM_LIT:1>])<EOL><DEDENT>return sample, tfd.MultivariateNormalDiag(loc=loc, scale_diag=scale_diag)<EOL>
Sample the dynamic latent prior.

        Args:
          samples: Number of samples to draw from the latent distribution.
          batch_size: Number of sequences to sample.
          length: Number of timesteps to sample for each sequence.
          fixed: Boolean for whether or not to share the same random
            sample across all sequences.

        Returns:
          A tuple of a sample tensor of shape [samples, batch_size, length
          latent_size], and a MultivariateNormalDiag distribution from which
          the tensor was sampled, with event shape [latent_size], and batch
          shape [samples, 1, length] if fixed or [samples, batch_size,
          length] otherwise.