class_docstr: Represents a vocabulary that can be built from a dataset.
docstr: Loads the vocab from disk (if `vocab_path` is given) or builds it from `tokenized_sequences`.
docstr_tok: ["Loads","the","vocab","from","disk","(","if","`","vocab_path","`","is","given",")","or","builds","it","from","`","tokenized_sequences","`","."]
code: def __init__(
      self,
      vocab_path: Optional[str] = None,
      tokenized_sequences: Optional[Iterable[Sequence[bytes]]] = None,
      min_freq: int = 1,
      pad_token: bytes = b"<pad>",
      unk_token: bytes = b"<unk>",
      bos_token: bytes = b"<s>",
      eos_token: bytes = b"</s>",
  ):
      """Loads the vocab from disk (if `vocab_path` is given) or builds it from `tokenized_sequences`."""
      self.pad_token = pad_token
      self.unk_token = unk_token
      self.bos_token = bos_token
      self.eos_token = eos_token
      self.special_tokens = (pad_token, unk_token, bos_token, eos_token)
  
      if vocab_path:
          self.load(vocab_path)
      elif tokenized_sequences is not None:
          self.build(tokenized_sequences, min_freq=min_freq)
      else:
          raise ValueError(
              (
                  "Vocabulary needs either `vocab_path` or `tokenized_sequences` to"
                  " be provided, got %r and %r."
              )
              % (vocab_path, tokenized_sequences)
          )
  
file_path: flax/examples/sst2/vocabulary.py
imports: import collections
  from typing import Iterable, Optional, Sequence
  from absl import logging
label_desc: Use image node_id 1 to create a new Vocabulary object  with example: obj = Vocabulary(vocab_path, tokenized_sequences, min_freq, pad_token, unk_token, bos_token, eos_token)