code: def _extend_control_events_default(control_events, events, state):
      """Default function for extending control event sequence.
  
      This function extends a control event sequence by duplicating the final event
      in the sequence.  The control event sequence will be extended to have length
      one longer than the generated event sequence.
  
      Args:
        control_events: The control event sequence to extend.
        events: The list of generated events.
        state: State maintained while generating, unused.
  
      Returns:
        The resulting state after extending the control sequence (in this case the
        state will be returned unmodified).
      """
      while len(control_events) <= len(events):
          control_events.append(control_events[-1])
      return state
  
imports: import collections
  import copy
  import functools
  from magenta.common import beam_search
  from magenta.common import state_util
  from magenta.contrib import training
  from magenta.models.shared import events_rnn_graph
  from magenta.models.shared import model
  import note_seq
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: _extend_control_events_default(control_events, events, state) and returns: state