def __init__(self, path, text_field, label_field, **kwargs):
cache_file = os.path.join(path, '<STR_LIT>')<EOL>fields = [('<STR_LIT:text>', text_field), ('<STR_LIT:label>', label_field)]<EOL>if os.path.exists(cache_file):<EOL><INDENT>with open(cache_file, '<STR_LIT:rb>') as fp:<EOL><INDENT>examples = pickle.load(fp)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>examples = []<EOL>for label in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>for fname in glob.iglob(os.path.join(path, label, '<STR_LIT>')):<EOL><INDENT>with io.open(fname, '<STR_LIT:r>', encoding="<STR_LIT:utf-8>") as f:<EOL><INDENT>text = f.readline()<EOL><DEDENT>examples.append(data.Example.fromlist([text, label], fields))<EOL><DEDENT><DEDENT>with open(cache_file, '<STR_LIT:wb>') as fp:<EOL><INDENT>pickle.dump(examples, file=fp)<EOL><DEDENT><DEDENT>data.Dataset.__init__(self, examples, fields, **kwargs)<EOL>
Create an IMDB dataset instance given a path and fields.

        Arguments:
            path: Path to the dataset's highest level directory
            text_field: The field that will be used for text data.
            label_field: The field that will be used for label data.
            Remaining keyword arguments: Passed to the constructor of
                data.Dataset.