@classmethod
def build(cls, path, min_freq=2, fix_len=20, **kwargs):
    '\n        Build a brand-new Parser, including initialization of all data fields and model parameters.\n\n        Args:\n            path (str):\n                The path of the model to be saved.\n            min_freq (str):\n                The minimum frequency needed to include a token in the vocabulary. Default: 2.\n            fix_len (int):\n                The max length of all subword pieces. The excess part of each piece will be truncated.\n                Required if using CharLSTM/BERT.\n                Default: 20.\n            kwargs (dict):\n                A dict holding the unconsumed arguments.\n        '
    args = Config(**locals())
    args.device = ('cuda' if torch.cuda.is_available() else 'cpu')
    os.makedirs((os.path.dirname(path) or './'), exist_ok=True)
    if (os.path.exists(path) and (not args.build)):
        parser = cls.load(**args)
        parser.model = cls.MODEL(**parser.args)
        parser.model.load_pretrained(parser.WORD.embed).to(args.device)
        return parser
    logger.info('Building the fields')
    (TAG, CHAR, ELMO, BERT) = (None, None, None, None)
    if (args.encoder != 'lstm'):
        from transformers import AutoTokenizer, GPT2Tokenizer, GPT2TokenizerFast
        t = AutoTokenizer.from_pretrained(args.bert)
        WORD = SubwordField('words', pad=t.pad_token, unk=t.unk_token, bos=(t.bos_token or t.cls_token), fix_len=args.fix_len, tokenize=t.tokenize, fn=(None if (not isinstance(t, (GPT2Tokenizer, GPT2TokenizerFast))) else (lambda x: (' ' + x))))
        WORD.vocab = t.get_vocab()
    else:
        WORD = Field('words', pad=PAD, unk=UNK, bos=BOS, lower=True)
        if ('tag' in args.feat):
            TAG = Field('tags', bos=BOS)
        if ('char' in args.feat):
            CHAR = SubwordField('chars', pad=PAD, unk=UNK, bos=BOS, fix_len=args.fix_len)
        if ('elmo' in args.feat):
            from allennlp.modules.elmo import batch_to_ids
            ELMO = RawField('elmo')
            ELMO.compose = (lambda x: batch_to_ids(x).to(WORD.device))
        if ('bert' in args.feat):
            from transformers import AutoTokenizer, GPT2Tokenizer, GPT2TokenizerFast
            t = AutoTokenizer.from_pretrained(args.bert)
            BERT = SubwordField('bert', pad=t.pad_token, unk=t.unk_token, bos=(t.bos_token or t.cls_token), fix_len=args.fix_len, tokenize=t.tokenize, fn=(None if (not isinstance(t, (GPT2Tokenizer, GPT2TokenizerFast))) else (lambda x: (' ' + x))))
            BERT.vocab = t.get_vocab()
    TEXT = RawField('texts')
    ARC = Field('arcs', bos=BOS, use_vocab=False, fn=CoNLL.get_arcs)
    SIB = ChartField('sibs', bos=BOS, use_vocab=False, fn=CoNLL.get_sibs)
    REL = Field('rels', bos=BOS)
    transform = CoNLL(FORM=(WORD, TEXT, CHAR, ELMO, BERT), CPOS=TAG, HEAD=(ARC, SIB), DEPREL=REL)
    train = Dataset(transform, args.train)
    if (args.encoder == 'lstm'):
        WORD.build(train, args.min_freq, (Embedding.load(args.embed, args.unk) if args.embed else None))
        if (TAG is not None):
            TAG.build(train)
        if (CHAR is not None):
            CHAR.build(train)
    REL.build(train)
    args.update({'n_words': (len(WORD.vocab) if (args.encoder != 'lstm') else WORD.vocab.n_init), 'n_rels': len(REL.vocab), 'n_tags': (len(TAG.vocab) if (TAG is not None) else None), 'n_chars': (len(CHAR.vocab) if (CHAR is not None) else None), 'char_pad_index': (CHAR.pad_index if (CHAR is not None) else None), 'bert_pad_index': (BERT.pad_index if (BERT is not None) else None), 'pad_index': WORD.pad_index, 'unk_index': WORD.unk_index, 'bos_index': WORD.bos_index})
    logger.info(f'{transform}')
    logger.info('Building the model')
    model = cls.MODEL(**args).load_pretrained((WORD.embed if hasattr(WORD, 'embed') else None)).to(args.device)
    logger.info(f'''{model}
''')
    return cls(args, model, transform)
Build a brand-new Parser, including initialization of all data fields and model parameters.

Args:
    path (str):
        The path of the model to be saved.
    min_freq (str):
        The minimum frequency needed to include a token in the vocabulary. Default: 2.
    fix_len (int):
        The max length of all subword pieces. The excess part of each piece will be truncated.
        Required if using CharLSTM/BERT.
        Default: 20.
    kwargs (dict):
        A dict holding the unconsumed arguments.
@classmethod
def build(cls, path, min_freq=2, fix_len=20, **kwargs):
    '\n        Build a brand-new Parser, including initialization of all data fields and model parameters.\n\n        Args:\n            path (str):\n                The path of the model to be saved.\n            min_freq (str):\n                The minimum frequency needed to include a token in the vocabulary. Default: 2.\n            fix_len (int):\n                The max length of all subword pieces. The excess part of each piece will be truncated.\n                Required if using CharLSTM/BERT.\n                Default: 20.\n            kwargs (dict):\n                A dict holding the unconsumed arguments.\n        '
    args = Config(**locals())
    args.device = ('cuda' if torch.cuda.is_available() else 'cpu')
    os.makedirs((os.path.dirname(path) or './'), exist_ok=True)
    if (os.path.exists(path) and (not args.build)):
        parser = cls.load(**args)
        parser.model = cls.MODEL(**parser.args)
        parser.model.load_pretrained(parser.WORD.embed).to(args.device)
        return parser
    logger.info('Building the fields')
    (TAG, CHAR, ELMO, BERT) = (None, None, None, None)
    if (args.encoder != 'lstm'):
        from transformers import AutoTokenizer, GPT2Tokenizer, GPT2TokenizerFast
        t = AutoTokenizer.from_pretrained(args.bert)
        WORD = SubwordField('words', pad=t.pad_token, unk=t.unk_token, bos=(t.bos_token or t.cls_token), fix_len=args.fix_len, tokenize=t.tokenize, fn=(None if (not isinstance(t, (GPT2Tokenizer, GPT2TokenizerFast))) else (lambda x: (' ' + x))))
        WORD.vocab = t.get_vocab()
    else:
        WORD = Field('words', pad=PAD, unk=UNK, bos=BOS, lower=True)
        if ('tag' in args.feat):
            TAG = Field('tags', bos=BOS)
        if ('char' in args.feat):
            CHAR = SubwordField('chars', pad=PAD, unk=UNK, bos=BOS, fix_len=args.fix_len)
        if ('elmo' in args.feat):
            from allennlp.modules.elmo import batch_to_ids
            ELMO = RawField('elmo')
            ELMO.compose = (lambda x: batch_to_ids(x).to(WORD.device))
        if ('bert' in args.feat):
            from transformers import AutoTokenizer, GPT2Tokenizer, GPT2TokenizerFast
            t = AutoTokenizer.from_pretrained(args.bert)
            BERT = SubwordField('bert', pad=t.pad_token, unk=t.unk_token, bos=(t.bos_token or t.cls_token), fix_len=args.fix_len, tokenize=t.tokenize, fn=(None if (not isinstance(t, (GPT2Tokenizer, GPT2TokenizerFast))) else (lambda x: (' ' + x))))
            BERT.vocab = t.get_vocab()
    TEXT = RawField('texts')
    ARC = Field('arcs', bos=BOS, use_vocab=False, fn=CoNLL.get_arcs)
    SIB = ChartField('sibs', bos=BOS, use_vocab=False, fn=CoNLL.get_sibs)
    REL = Field('rels', bos=BOS)
    transform = CoNLL(FORM=(WORD, TEXT, CHAR, ELMO, BERT), CPOS=TAG, HEAD=(ARC, SIB), DEPREL=REL)
    train = Dataset(transform, args.train)
    if (args.encoder == 'lstm'):
        WORD.build(train, args.min_freq, (Embedding.load(args.embed, args.unk) if args.embed else None))
        if (TAG is not None):
            TAG.build(train)
        if (CHAR is not None):
            CHAR.build(train)
    REL.build(train)
    args.update({'n_words': (len(WORD.vocab) if (args.encoder != 'lstm') else WORD.vocab.n_init), 'n_rels': len(REL.vocab), 'n_tags': (len(TAG.vocab) if (TAG is not None) else None), 'n_chars': (len(CHAR.vocab) if (CHAR is not None) else None), 'char_pad_index': (CHAR.pad_index if (CHAR is not None) else None), 'bert_pad_index': (BERT.pad_index if (BERT is not None) else None), 'pad_index': WORD.pad_index, 'unk_index': WORD.unk_index, 'bos_index': WORD.bos_index})
    logger.info(f'{transform}')
    logger.info('Building the model')
    model = cls.MODEL(**args).load_pretrained((WORD.embed if hasattr(WORD, 'embed') else None)).to(args.device)
    logger.info(f'{model}
')
    return cls(args, model, transform)