elif isinstance(var, relativedelta.relativedelta):
            return cls._encode(encode_relativedelta(var), type_=DAT.RELATIVEDELTA)
        elif callable(var):
            return str(get_python_source(var))
        elif isinstance(var, set):
            
            try:
                return cls._encode(sorted(cls.serialize(v, strict=strict) for v in var), type_=DAT.SET)
            except TypeError:
                return cls._encode([cls.serialize(v, strict=strict) for v in var], type_=DAT.SET)
        elif isinstance(var, tuple):
            
            return cls._encode([cls.serialize(v, strict=strict) for v in var], type_=DAT.TUPLE)
        elif isinstance(var, TaskGroup):
            return TaskGroupSerialization.serialize_task_group(var)
        elif isinstance(var, Param):
            return cls._encode(cls._serialize_param(var), type_=DAT.PARAM)
        elif isinstance(var, XComArg):
            return cls._encode(serialize_xcom_arg(var), type_=DAT.XCOM_REF)
        elif isinstance(var, Dataset):
            return cls._encode(dict(uri=var.uri, extra=var.extra), type_=DAT.DATASET)
        elif isinstance(var, SimpleTaskInstance):
            return cls._encode(cls.serialize(var.__dict__, strict=strict), type_=DAT.SIMPLE_TASK_INSTANCE)
        else:
            log.debug("Cast type %s to str in serialization.", type(var))
            if strict:
                raise SerializationError("Encountered unexpected type")
            return str(var)
    @classmethod
    def deserialize(cls, encoded_var: Any) -> Any: