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 a dictionary.
  
  Parameters
  ----------
  serialized_dict: `dict`
      The serialized dictionary.
  obj_type: `str`
      The type of the object to be deserialized. Must be "dict".
  
  Returns
  -------
  obj: `dict`
      The deserialized dictionary.
docstr_tok: ["Deserializes","a","dictionary",".","Parameters","--","--","--","--","--","serialized_dict",":","`","dict","`","The","serialized","dictionary",".","obj_type",":","`","str","`","The","type","of","the","object","to","be","deserialized",".","Must","be","``","dict","''",".","Returns","--","--","--","-","obj",":","`","dict","`","The","deserialized","dictionary","."]
code: def _deserialize_dict(self, serialized_dict, obj_type):
      """Deserializes a dictionary.
  
      Parameters
      ----------
      serialized_dict: `dict`
          The serialized dictionary.
      obj_type: `str`
          The type of the object to be deserialized. Must be "dict".
  
      Returns
      -------
      obj: `dict`
          The deserialized dictionary.
      """
      if obj_type != dict.__name__:
          raise ValueError("The obj_type must be dict.")
  
      (
          pickles,
          directories,
          obj_types,
      ) = self._get_keys_from_serialized_dict(serialized_dict)
      result = {}
      elements = pickles + directories
      keys = [element for element in elements if KEY_SUFFIX in element]
      # Iterates through keys and finds the corresponding values.
      for element in keys:
          if PICKLE_KEY_EXTENSION in element:
              key = self.loads_from_str(serialized_dict[element])
          else:
              key = self.loads(
                  serialized_dict[element],
                  obj_types[element.split(".")[0]],
              )
  
          # Searches for the value corresponding to the key.
          element = element.replace(KEY_SUFFIX, VALUE_SUFFIX).split(
              "."
          )[0]
          # Value name could be either with .pkl or a directory.
          if f"{element}{PICKLE_KEY_EXTENSION}" in pickles:
              element = f"{element}{PICKLE_KEY_EXTENSION}"
              value = self.loads_from_str(serialized_dict[element])
          elif f"{element}{DIRECTORY_KEY_EXTENSION}" in directories:
              element = f"{element}{DIRECTORY_KEY_EXTENSION}"
              value = self.loads(
                  serialized_dict[element],
                  obj_types[element.split(".")[0]],
              )
          else:
              raise ValueError(f"Value not found for key {key}.")
          # Sets the key, value pair.
          result[key] = value
  
      return result
  
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 10 for calling the GreykitePickler obj's underlying member method code with example usage: obj._deserialize_dict(serialized_dict, obj_type) and returns: result