def sample(self, num_samples, batch_size, dis, start_letter=cfg.start_letter, train=False):
        """
        Samples the network and returns num_samples samples of length max_seq_len.
        :return: samples: batch_size * max_seq_len
        """
        num_batch = num_samples // batch_size + 1 if num_samples != batch_size else 1
        samples = torch.zeros(num_batch * batch_size, self.max_seq_len).long()  # larger than num_samples
        fake_sentences = torch.zeros((batch_size, self.max_seq_len))

        for b in range(num_batch):
            leak_sample, _, _, _ = self.forward_leakgan(fake_sentences, dis, if_sample=True, no_log=False
                                                        , start_letter=start_letter, train=False)

            assert leak_sample.shape == (batch_size, self.max_seq_len)
            samples[b * batch_size:(b + 1) * batch_size, :] = leak_sample

        samples = samples[:num_samples, :]

        return samples  # cut to num_samples

        Samples the network and returns num_samples samples of length max_seq_len.
        :return: samples: batch_size * max_seq_len
        
models/LeakGAN_G.py