class_docstr: Stores a polyphonic sequence as a stream of single-note events.
  
  Events are PolyphonicEvent tuples that encode event type and pitch.
class_docstr_tok: ["Stores","a","polyphonic","sequence","as","a","stream","of","single-note","events",".","Events","are","PolyphonicEvent","tuples","that","encode","event","type","and","pitch","."]
docstr: Sets the length of the sequence to the specified number of steps.
  
  If the event sequence is not long enough, pads with silence to make the
  sequence the specified length. If it is too long, it will be truncated to
  the requested length.
  
  Note that this will append a STEP_END event to the end of the sequence if
  there is an unfinished step.
  
  Args:
    steps: How many quantized steps long the event sequence should be.
    from_left: Whether to add/remove from the left instead of right.
docstr_tok: ["Sets","the","length","of","the","sequence","to","the","specified","number","of","steps",".","If","the","event","sequence","is","not","long","enough",",","pads","with","silence","to","make","the","sequence","the","specified","length",".","If","it","is","too","long",",","it","will","be","truncated","to","the","requested","length",".","Note","that","this","will","append","a","STEP_END","event","to","the","end","of","the","sequence","if","there","is","an","unfinished","step",".","Args",":","steps",":","How","many","quantized","steps","long","the","event","sequence","should","be",".","from_left",":","Whether","to","add\/remove","from","the","left","instead","of","right","."]
code: def set_length(self, steps, from_left=False):
      """Sets the length of the sequence to the specified number of steps.
  
      If the event sequence is not long enough, pads with silence to make the
      sequence the specified length. If it is too long, it will be truncated to
      the requested length.
  
      Note that this will append a STEP_END event to the end of the sequence if
      there is an unfinished step.
  
      Args:
        steps: How many quantized steps long the event sequence should be.
        from_left: Whether to add/remove from the left instead of right.
      """
      if from_left:
          raise NotImplementedError("from_left is not supported")
  
      # First remove any trailing end events.
      self.trim_trailing_end_events()
      # Then add an end step event, to close out any incomplete steps.
      self._events.append(
          PolyphonicEvent(
              event_type=PolyphonicEvent.STEP_END, pitch=None
          )
      )
      # Then trim or pad as needed.
      if self.num_steps < steps:
          self._append_silence_steps(steps - self.num_steps)
      elif self.num_steps > steps:
          self._trim_steps(self.num_steps - steps)
      # Then add a trailing end event.
      self._events.append(
          PolyphonicEvent(event_type=PolyphonicEvent.END, pitch=None)
      )
      assert self.num_steps == steps
  
imports: from __future__ import division
  import collections
  import copy
  from magenta.pipelines import statistics
  from note_seq import constants
  from note_seq import events_lib
  from note_seq import sequences_lib
  from note_seq.protobuf import music_pb2
  from six.moves import range
  import tensorflow.compat.v1
label_desc: Use image node_id 7 for calling the PolyphonicSequence obj's underlying member method code with example usage: obj.set_length(steps, from_left) without return types