class_docstr: Represents a parameter dictionary with a history, and contains other functionality around
  parameter passing and validation for AllenNLP.
  
  There are currently two benefits of a `Params` object over a plain dictionary for parameter
  passing:
  
  1. We handle a few kinds of parameter validation, including making sure that parameters
     representing discrete choices actually have acceptable values, and making sure no extra
     parameters are passed.
  2. We log all parameter reads, including default values.  This gives a more complete
     specification of the actual parameters used than is given in a JSON file, because
     those may not specify what default values were used, whereas this will log them.
  
  !!! Consumption
      The convention for using a `Params` object in AllenNLP is that you will consume the parameters
      as you read them, so that there are none left when you've read everything you expect.  This
      lets us easily validate that you didn't pass in any `extra` parameters, just by making sure
      that the parameter dictionary is empty.  You should do this when you're done handling
      parameters, by calling `Params.assert_empty`.
class_docstr_tok: ["Represents","a","parameter","dictionary","with","a","history",",","and","contains","other","functionality","around","parameter","passing","and","validation","for","AllenNLP",".","There","are","currently","two","benefits","of","a","`","Params","`","object","over","a","plain","dictionary","for","parameter","passing",":","1",".","We","handle","a","few","kinds","of","parameter","validation",",","including","making","sure","that","parameters","representing","discrete","choices","actually","have","acceptable","values",",","and","making","sure","no","extra","parameters","are","passed",".","2",".","We","log","all","parameter","reads",",","including","default","values",".","This","gives","a","more","complete","specification","of","the","actual","parameters","used","than","is","given","in","a","JSON","file",",","because","those","may","not","specify","what","default","values","were","used",",","whereas","this","will","log","them",".","!","!","!","Consumption","The","convention","for","using","a","`","Params","`","object","in","AllenNLP","is","that","you","will","consume","the","parameters","as","you","read","them",",","so","that","there","are","none","left","when","you","'ve","read","everything","you","expect",".","This","lets","us","easily","validate","that","you","did","n't","pass","in","any","`","extra","`","parameters",",","just","by","making","sure","that","the","parameter","dictionary","is","empty",".","You","should","do","this","when","you","'re","done","handling","parameters",",","by","calling","`","Params.assert_empty","`","."]
code: def to_file(
      self, params_file: str, preference_orders: List[List[str]] = None
  ) -> None:
      with open(params_file, "w") as handle:
          json.dump(
              self.as_ordered_dict(preference_orders), handle, indent=4
          )
  
imports: import copy
  from itertools import chain
  import json
  import logging
  import os
  import zlib
  from collections import OrderedDict
  from collections.abc import MutableMapping
  from os import PathLike
  from typing import Any, Dict, List, Union, Optional, TypeVar, Iterable, Set
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.file_utils import cached_path
label_desc: Use image node_id 19 for calling the Params obj's underlying member method code with example usage: obj.to_file(params_file, preference_orders) without return types