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 class.
  
   Parameters
  ----------
  serialized_dict: `dict`
      The serialized dictionary.
  obj_type: `str`
      The type of the object to be deserialized. Must be instance of a class.
  
  Returns
  -------
  obj: `class`
      The deserialized class.
docstr_tok: ["Deserializes","a","class",".","Parameters","--","--","--","--","--","serialized_dict",":","`","dict","`","The","serialized","dictionary",".","obj_type",":","`","str","`","The","type","of","the","object","to","be","deserialized",".","Must","be","instance","of","a","class",".","Returns","--","--","--","-","obj",":","`","class","`","The","deserialized","class","."]
code: def _deserialize_class(self, serialized_dict, obj_type):
      """Deserializes a class.
  
       Parameters
      ----------
      serialized_dict: `dict`
          The serialized dictionary.
      obj_type: `str`
          The type of the object to be deserialized. Must be instance of a class.
  
      Returns
      -------
      obj: `class`
          The deserialized class.
      """
      (
          pickles,
          directories,
          obj_types,
      ) = self._get_keys_from_serialized_dict(serialized_dict)
      # Object is a class instance.
      # Creates the class instance and sets the attributes.
      # Some class has required args during initialization,
      # these args are pulled from attributes.
      init_params = list(
          inspect.signature(obj_type.__init__).parameters
      )  # init args
      elements = pickles + directories
      # Gets the attribute names and their values in a dictionary.
      values = {}
      for element in elements:
          if PICKLE_KEY_EXTENSION in element:
              values[element.split(".")[0]] = self.loads_from_str(
                  serialized_dict[element]
              )
          else:
              values[element.split(".")[0]] = self.loads(
                  serialized_dict=serialized_dict[element],
                  obj_type=obj_types[element.split(".")[0]],
              )
      # Gets the init args from values.
      init_dict = {
          key: value
          for key, value in values.items()
          if key in init_params
      }
      # Some attributes have a "_" at the beginning.
      init_dict.update(
          {
              key[1:]: value
              for key, value in values.items()
              if (key[1:] in init_params and key[0] == "_")
          }
      )
      # ``design_info`` does not have column_names attribute,
      # which is required during init.
      # The column_names param is pulled from the column_name_indexes attribute.
      # This can be omitted once we allow dumping @property attributes.
      if "column_names" in init_params:
          init_dict["column_names"] = values[
              "column_name_indexes"
          ].keys()
      # Creates the instance.
      result = obj_type(**init_dict)
      # Sets the attributes.
      for key, value in values.items():
          setattr(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 12 for calling the GreykitePickler obj's underlying member method code with example usage: obj._deserialize_class(serialized_dict, obj_type) and returns: result