def build_vocab(self, *args, **kwargs):
        """Construct the Vocab object for nesting field and combine it with this field's vocab.

        Arguments:
            Positional arguments: Dataset objects or other iterable data
                sources from which to construct the Vocab object that
                represents the set of possible values for the nesting field. If
                a Dataset object is provided, all columns corresponding
                to this field are used; individual columns can also be
                provided directly.
            Remaining keyword arguments: Passed to the constructor of Vocab.
        """
        sources = []
        for arg in args:
            if isinstance(arg, Dataset):
                sources.extend(
                    [getattr(arg, name) for name, field in arg.fields.items()
                     if field is self]
                )
            else:
                sources.append(arg)

        flattened = []
        for source in sources:
            flattened.extend(source)
        old_vectors = None
        old_unk_init = None
        old_vectors_cache = None
        if "vectors" in kwargs.keys():
            old_vectors = kwargs["vectors"]
            kwargs["vectors"] = None
        if "unk_init" in kwargs.keys():
            old_unk_init = kwargs["unk_init"]
            kwargs["unk_init"] = None
        if "vectors_cache" in kwargs.keys():
            old_vectors_cache = kwargs["vectors_cache"]
            kwargs["vectors_cache"] = None
        # just build vocab and does not load vector
        self.nesting_field.build_vocab(*flattened, **kwargs)
        super(NestedField, self).build_vocab()
        self.vocab.extend(self.nesting_field.vocab)
        self.vocab.freqs = self.nesting_field.vocab.freqs.copy()
        if old_vectors is not None:
            self.vocab.load_vectors(old_vectors,
                                    unk_init=old_unk_init, cache=old_vectors_cache)

        self.nesting_field.vocab = self.vocab
def build_vocab ( self , * args , ** kwargs ) : sources = [ ] for arg in args : if isinstance ( arg , Dataset ) : sources . extend ( [ getattr ( arg , name ) for name , field in arg . fields . items ( ) if field is self ] ) else : sources . append ( arg ) flattened = [ ] for source in sources : flattened . extend ( source ) old_vectors = None old_unk_init = None old_vectors_cache = None if "vectors" in kwargs . keys ( ) : old_vectors = kwargs [ "vectors" ] kwargs [ "vectors" ] = None if "unk_init" in kwargs . keys ( ) : old_unk_init = kwargs [ "unk_init" ] kwargs [ "unk_init" ] = None if "vectors_cache" in kwargs . keys ( ) : old_vectors_cache = kwargs [ "vectors_cache" ] kwargs [ "vectors_cache" ] = None self . nesting_field . build_vocab ( * flattened , ** kwargs ) super ( NestedField , self ) . build_vocab ( ) self . vocab . extend ( self . nesting_field . vocab ) self . vocab . freqs = self . nesting_field . vocab . freqs . copy ( ) if old_vectors is not None : self . vocab . load_vectors ( old_vectors , unk_init = old_unk_init , cache = old_vectors_cache ) self . nesting_field . vocab = self . vocab
Construct the Vocab object for nesting field and combine it with this field's vocab.

        Arguments:
            Positional arguments: Dataset objects or other iterable data
                sources from which to construct the Vocab object that
                represents the set of possible values for the nesting field. If
                a Dataset object is provided, all columns corresponding
                to this field are used; individual columns can also be
                provided directly.
            Remaining keyword arguments: Passed to the constructor of Vocab.