<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_dict(cls, val):
 """Creates dict2 object from dict object Args: val (:obj:`dict`):
 Value to create from Returns: Equivalent dict2 object. """

        if isinstance(val, dict2):
            return val

        elif isinstance(val, dict):
            res = cls()
            for k, v in val.items():
                res[k] = cls.from_dict(v)
            return res

        elif isinstance(val, list):
            res = []
            for item in val:
                res.append(cls.from_dict(item))
            return res
        else:
            return val