'Generate a melody from a primer melody.
Args:
num_steps: The integer length in steps of the final melody, after
generation. Includes the primer.
primer_melody: The primer melody, a Melody object.
temperature: A float specifying how much to divide the logits by
before computing the softmax. Greater than 1.0 makes melodies more
random, less than 1.0 makes melodies less random.
beam_size: An integer, beam size to use when generating melodies via beam
search.
branch_factor: An integer, beam search branch factor to use.
steps_per_iteration: An integer, number of melody steps to take per beam
search iteration.
Returns:
The generated Melody object (which begins with the provided primer
melody).'

def generate_melody(self, num_steps, primer_melody, temperature=1.0, beam_size=1, branch_factor=1, steps_per_iteration=1):

    melody = copy.deepcopy(primer_melody)
    transpose_amount = melody.squash(self._config.min_note, self._config.max_note, self._config.transpose_to_key)
    melody = self._generate_events(num_steps, melody, temperature, beam_size, branch_factor, steps_per_iteration)
    melody.transpose((- transpose_amount))
    return melody
