Drupal ui inside module
Yes that's wrong, you need to put it inside a hook function. 

Which one depends on where you're trying to use it. To add it to a render array, for example a form, you might use

$form['#attached']['library'][] = array('system', 'ui.accordion');