dag._task_group = TaskGroup.create_root(dag)
            for task in dag.tasks:
                dag.task_group.add(task)
        
        if "has_on_success_callback" in encoded_dag:
            dag.has_on_success_callback = True
        if "has_on_failure_callback" in encoded_dag:
            dag.has_on_failure_callback = True
        keys_to_set_none = dag.get_serialized_fields() - encoded_dag.keys() - cls._CONSTRUCTOR_PARAMS.keys()
        for k in keys_to_set_none:
            setattr(dag, k, None)
        for task in dag.task_dict.values():
            task.dag = dag
            for date_attr in ["start_date", "end_date"]:
                if getattr(task, date_attr) is None:
                    setattr(task, date_attr, getattr(dag, date_attr))
            if task.subdag is not None:
                setattr(task.subdag, "parent_dag", dag)
            
            for k in ("expand_input", "op_kwargs_expand_input"):
                kwargs_ref = getattr(task, k, None)
                if isinstance(kwargs_ref, _ExpandInputRef):
                    setattr(task, k, kwargs_ref.deref(dag))
            for task_id in task.downstream_task_ids:
                
                dag.task_dict[task_id].upstream_task_ids.add(task.task_id)
        return dag
    @classmethod
    def to_dict(cls, var: Any) -> dict: