human
Complete the below
def get_or_generate_vocab(data_dir, tmp_dir, vocab_filename, vocab_size, sources=None):

    ''''Generate a vocabulary from the datasets in sources (_DATA_FILE_URLS).'
    '''

=====
Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.
    sources = (sources or _DATA_FILE_URLS)
    def generate():
        tf.logging.info('Generating    vocab    from:    %s', str(sources))
        for source in sources:
            url = source[0]
            filename = os.path.basename(url)
            read_type = ('r:gz' if ('tgz' in filename) else 'r')
            compressed_file = maybe_download(tmp_dir, filename, url)
            with tarfile.open(compressed_file, read_type) as corpus_tar:
                corpus_tar.extractall(tmp_dir)
            for lang_file in source[1]:
                tf.logging.info(('Reading    file:    %s' % lang_file))
                filepath = os.path.join(tmp_dir, lang_file)
                if ('.gz' in lang_file):
                    new_filepath = os.path.join(tmp_dir, lang_file[:(-3)])
                    if tf.gfile.Exists(new_filepath):
                        tf.logging.info(('Subdirectory    %s    already    exists,    skipping    unpacking' % filepath))
                    else:
                        tf.logging.info(('Unpacking    subdirectory    %s' % filepath))
                        gunzip_file(filepath, new_filepath)
                    filepath = new_filepath
                with tf.gfile.GFile(filepath, mode='r') as source_file:
                    file_byte_budget = (350000.0 if filepath.endswith('en') else 700000.0)
                    for line in source_file:
                        if (file_byte_budget <= 0):
                            break
                        line = line.strip()
                        file_byte_budget -= len(line)
                        (yield line)
    return get_or_generate_vocab_inner(data_dir, vocab_filename, vocab_size, generator_fn=generate)