class_docstr: Extends the functionality of dill to serialize arbitrary objects.
  
  Originally intended to serialize the anomaly detector class
  `~greykite.detection.anomaly_detector.AnomalyDetector`, but
  can be potentially used to serialize other objects.
  
  Outputs a dictionary that can be serialized by `json` or `yaml` libraries.
  The dictionary has a tree structure, where each node is either a
  serialized object, or a pair of type and directory of serialized objects.
  The base of the directory is called "ROOT".
  
  Usage
  -----
      # To serialize
      pickler = GreykitePickler()
      pickled = pickler.dumps(obj)
      pickled_json = json.dumps(pickled)
  
      # To deserialize
      pickled = json.loads(pickled_json)
      obj = pickler.loads(pickled)
  
  Attributes
  ----------
  obj: any
      The object to be serialized.
class_docstr_tok: ["Extends","the","functionality","of","dill","to","serialize","arbitrary","objects",".","Originally","intended","to","serialize","the","anomaly","detector","class","`","~greykite.detection.anomaly_detector.AnomalyDetector","`",",","but","can","be","potentially","used","to","serialize","other","objects",".","Outputs","a","dictionary","that","can","be","serialized","by","`","json","`","or","`","yaml","`","libraries",".","The","dictionary","has","a","tree","structure",",","where","each","node","is","either","a","serialized","object",",","or","a","pair","of","type","and","directory","of","serialized","objects",".","The","base","of","the","directory","is","called","``","ROOT","''",".","Usage","--","--","-","#","To","serialize","pickler","=","GreykitePickler","(",")","pickled","=","pickler.dumps","(","obj",")","pickled_json","=","json.dumps","(","pickled",")","#","To","deserialize","pickled","=","json.loads","(","pickled_json",")","obj","=","pickler.loads","(","pickled",")","Attributes","--","--","--","--","--","obj",":","any","The","object","to","be","serialized","."]
docstr: Deserializes the root object.
  This is the very top level of the nested `serialized_dict`.
  Thus, it either contains a single .pkl file or a single .type + .dir pair.
  
  Parameters
  ----------
  serialized_dict: `dict`
      The serialized dictionary.
  obj_type: `str`
      The type of the object to be deserialized. Must be "ROOT".
  
  Returns
  -------
  obj: any
      The deserialized object.
docstr_tok: ["Deserializes","the","root","object",".","This","is","the","very","top","level","of","the","nested","`","serialized_dict","`",".","Thus",",","it","either","contains","a","single",".pkl","file","or","a","single",".type","+",".dir","pair",".","Parameters","--","--","--","--","--","serialized_dict",":","`","dict","`","The","serialized","dictionary",".","obj_type",":","`","str","`","The","type","of","the","object","to","be","deserialized",".","Must","be","``","ROOT","''",".","Returns","--","--","--","-","obj",":","any","The","deserialized","object","."]
code: def _deserialize_root(self, serialized_dict, obj_type):
      """Deserializes the root object.
      This is the very top level of the nested `serialized_dict`.
      Thus, it either contains a single .pkl file or a single .type + .dir pair.
  
      Parameters
      ----------
      serialized_dict: `dict`
          The serialized dictionary.
      obj_type: `str`
          The type of the object to be deserialized. Must be "ROOT".
  
      Returns
      -------
      obj: any
          The deserialized object.
      """
      if obj_type != OBJECT_TYPE_ROOT:
          raise ValueError(f"The obj_type must be {OBJECT_TYPE_ROOT}.")
  
      (
          pickles,
          directories,
          obj_types,
      ) = self._get_keys_from_serialized_dict(serialized_dict)
      if len(pickles) > 1 or len(directories) > 1:
          raise ValueError("Multiple elements found in the top level.")
      if f"{OBJECT_TYPE_ROOT}{PICKLE_KEY_EXTENSION}" in pickles:
          # The only 1 .pkl file case.
          return self.loads_from_str(
              serialized_dict[
                  f"{OBJECT_TYPE_ROOT}{PICKLE_KEY_EXTENSION}"
              ]
          )
      else:
          # The .type + .dir case.
          return self.loads(
              serialized_dict[
                  f"{OBJECT_TYPE_ROOT}{DIRECTORY_KEY_EXTENSION}"
              ],
              obj_types[OBJECT_TYPE_ROOT],
          )
  
file_path: greykite/greykite/detection/common/pickler.py
imports: import codecs
  import inspect
  from collections import OrderedDict
  import dill
label_desc: Use image node_id 8 for calling the GreykitePickler obj's underlying member method code with example usage: obj._deserialize_root(serialized_dict, obj_type) and returns: self, self