class_docstr: A nested field.
  
  A nested field holds another field (called *nesting field*), accepts an untokenized
  string or a list string tokens and groups and treats them as one field as described
  by the nesting field. Every token will be preprocessed, padded, etc. in the manner
  specified by the nesting field. Note that this means a nested field always has
  ``sequential=True``. The two fields' vocabularies will be shared. Their
  numericalization results will be stacked into a single tensor. And NestedField will
  share the same include_lengths with nesting_field, so one shouldn't specify the
  include_lengths in the nesting_field. This field is
  primarily used to implement character embeddings. See ``tests/data/test_field.py``
  for examples on how to use this field.
  
  Arguments:
      nesting_field (Field): A field contained in this nested field.
      use_vocab (bool): Whether to use a Vocab object. If False, the data in this
          field should already be numerical. Default: ``True``.
      init_token (str): A token that will be prepended to every example using this
          field, or None for no initial token. Default: ``None``.
      eos_token (str): A token that will be appended to every example using this
          field, or None for no end-of-sentence token. Default: ``None``.
      fix_length (int): A fixed length that all examples using this field will be
          padded to, or ``None`` for flexible sequence lengths. Default: ``None``.
      dtype: The torch.dtype class that represents a batch of examples
          of this kind of data. Default: ``torch.long``.
      preprocessing (Pipeline): The Pipeline that will be applied to examples
          using this field after tokenizing but before numericalizing. Many
          Datasets replace this attribute with a custom preprocessor.
          Default: ``None``.
      postprocessing (Pipeline): A Pipeline that will be applied to examples using
          this field after numericalizing but before the numbers are turned
          into a Tensor. The pipeline function takes the batch as a list, and
          the field's Vocab. Default: ``None``.
      include_lengths: Whether to return a tuple of a padded minibatch and
          a list containing the lengths of each examples, or just a padded
          minibatch. Default: False.
      tokenize: The function used to tokenize strings using this field into
          sequential examples. If "spacy", the SpaCy tokenizer is
          used. If a non-serializable function is passed as an argument,
          the field will not be able to be serialized. Default: string.split.
      tokenizer_language: The language of the tokenizer to be constructed.
          Various languages currently supported only in SpaCy.
      pad_token (str): The string token used as padding. If ``nesting_field`` is
          sequential, this will be set to its ``pad_token``. Default: ``"<pad>"``.
      pad_first (bool): Do the padding of the sequence at the beginning. Default:
          ``False``.
class_docstr_tok: ["A","nested","field",".","A","nested","field","holds","another","field","(","called","*","nesting","field","*",")",",","accepts","an","untokenized","string","or","a","list","string","tokens","and","groups","and","treats","them","as","one","field","as","described","by","the","nesting","field",".","Every","token","will","be","preprocessed",",","padded",",","etc",".","in","the","manner","specified","by","the","nesting","field",".","Note","that","this","means","a","nested","field","always","has","``","sequential=True","``",".","The","two","fields","'","vocabularies","will","be","shared",".","Their","numericalization","results","will","be","stacked","into","a","single","tensor",".","And","NestedField","will","share","the","same","include_lengths","with","nesting_field",",","so","one","should","n't","specify","the","include_lengths","in","the","nesting_field",".","This","field","is","primarily","used","to","implement","character","embeddings",".","See","``","tests\/data\/test_field.py","``","for","examples","on","how","to","use","this","field",".","Arguments",":","nesting_field","(","Field",")",":","A","field","contained","in","this","nested","field",".","use_vocab","(","bool",")",":","Whether","to","use","a","Vocab","object",".","If","False",",","the","data","in","this","field","should","already","be","numerical",".","Default",":","``","True","``",".","init_token","(","str",")",":","A","token","that","will","be","prepended","to","every","example","using","this","field",",","or","None","for","no","initial","token",".","Default",":","``","None","``",".","eos_token","(","str",")",":","A","token","that","will","be","appended","to","every","example","using","this","field",",","or","None","for","no","end-of-sentence","token",".","Default",":","``","None","``",".","fix_length","(","int",")",":","A","fixed","length","that","all","examples","using","this","field","will","be","padded","to",",","or","``","None","``","for","flexible","sequence","lengths",".","Default",":","``","None","``",".","dtype",":","The","torch.dtype","class","that","represents","a","batch","of","examples","of","this","kind","of","data",".","Default",":","``","torch.long","``",".","preprocessing","(","Pipeline",")",":","The","Pipeline","that","will","be","applied","to","examples","using","this","field","after","tokenizing","but","before","numericalizing",".","Many","Datasets","replace","this","attribute","with","a","custom","preprocessor",".","Default",":","``","None","``",".","postprocessing","(","Pipeline",")",":","A","Pipeline","that","will","be","applied","to","examples","using","this","field","after","numericalizing","but","before","the","numbers","are","turned","into","a","Tensor",".","The","pipeline","function","takes","the","batch","as","a","list",",","and","the","field","'s","Vocab",".","Default",":","``","None","``",".","include_lengths",":","Whether","to","return","a","tuple","of","a","padded","minibatch","and","a","list","containing","the","lengths","of","each","examples",",","or","just","a","padded","minibatch",".","Default",":","False",".","tokenize",":","The","function","used","to","tokenize","strings","using","this","field","into","sequential","examples",".","If","``","spacy","''",",","the","SpaCy","tokenizer","is","used",".","If","a","non-serializable","function","is","passed","as","an","argument",",","the","field","will","not","be","able","to","be","serialized",".","Default",":","string.split",".","tokenizer_language",":","The","language","of","the","tokenizer","to","be","constructed",".","Various","languages","currently","supported","only","in","SpaCy",".","pad_token","(","str",")",":","The","string","token","used","as","padding",".","If","``","nesting_field","``","is","sequential",",","this","will","be","set","to","its","``","pad_token","``",".","Default",":","``","``","<","pad",">","''","``",".","pad_first","(","bool",")",":","Do","the","padding","of","the","sequence","at","the","beginning",".","Default",":","``","False","``","."]
docstr: 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.
docstr_tok: ["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","."]
code: 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
  
imports: from collections import Counter, OrderedDict
  from itertools import chain
  import torch
  from torchtext.data.utils import dtype_to_attr, get_tokenizer, is_tokenizer_serializable
  from ..vocab import Vocab
  from .dataset import Dataset
  from .pipeline import Pipeline
label_desc: Use image node_id 4 for calling the NestedField obj's underlying member method code with example usage: obj.build_vocab() without return types