code: def sm_to_dot(model):
      
  
      dot_str = HEADER
  
      # Render states
      first = True
      for state in model.states:
          dot_str += '{}[label="{{{}{}|{}}}"]\n'.format(
              id(state), r"-\> " if first else "", state.name,
              "\\n".join(action.name for action in state.actions))
          first = False
  
          # Render transitions
          for transition in state.transitions:
              dot_str += '{} -> {} [label="{}"]\n'\
                  .format(id(state), id(transition.to_state),
                          transition.event.name)
  
      # If there are reset events declared render them.
      if model.resetEvents:
          dot_str += 'reset_events [label="{{Reset Events|{}}}", style=""]\n'\
              .format("\\n".join(event.name for event in model.resetEvents))
  
      dot_str += '\n}\n'
      return dot_str
docs: Transforms given state machine model to dot str.