<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def __gen_opts(self, opts):
        '''
        The options used by the High State object are derived from options
        on the minion and the master, or just the minion if the high state
        call is entirely local.
        '''
        # If the state is intended to be applied locally, then the local opts
        # should have all of the needed data, otherwise overwrite the local
        # data items with data from the master
        if 'local_state' in opts:
            if opts['local_state']:
                return opts
        mopts = self.client.master_opts()
        if not isinstance(mopts, dict):
            # An error happened on the master
            opts['renderer'] = 'jinja|yaml'
            opts['failhard'] = False
            opts['state_top'] = salt.utils.url.create('top.sls')
            opts['nodegroups'] = {}
            opts['file_roots'] = {'base': [syspaths.BASE_FILE_ROOTS_DIR]}
        else:
            opts['renderer'] = mopts['renderer']
            opts['failhard'] = mopts.get('failhard', False)
            if mopts['state_top'].startswith('salt://'):
                opts['state_top'] = mopts['state_top']
            elif mopts['state_top'].startswith('/'):
                opts['state_top'] = salt.utils.url.create(mopts['state_top'][1:])
            else:
                opts['state_top'] = salt.utils.url.create(mopts['state_top'])
            opts['state_top_saltenv'] = mopts.get('state_top_saltenv', None)
            opts['nodegroups'] = mopts.get('nodegroups', {})
            opts['state_auto_order'] = mopts.get(
                'state_auto_order',
                opts['state_auto_order'])
            opts['file_roots'] = mopts['file_roots']
            opts['top_file_merging_strategy'] = mopts.get('top_file_merging_strategy',
                                                           opts.get('top_file_merging_strategy'))
            opts['env_order'] = mopts.get('env_order', opts.get('env_order', []))
            opts['default_top'] = mopts.get('default_top', opts.get('default_top'))
            opts['state_events'] = mopts.get('state_events')
            opts['state_aggregate'] = mopts.get('state_aggregate', opts.get('state_aggregate', False))
            opts['jinja_env'] = mopts.get('jinja_env', {})
            opts['jinja_sls_env'] = mopts.get('jinja_sls_env', {})
            opts['jinja_lstrip_blocks'] = mopts.get('jinja_lstrip_blocks', False)
            opts['jinja_trim_blocks'] = mopts.get('jinja_trim_blocks', False)
        return opts