docs: def as_constraint(cls, constraint, model, constraint_type=None, **init_kwargs):
          """
          Initiate a Model which should serve as a constraint. Such a
          constraint-model should be initiated with knowledge of another
          ``BaseModel``, from which it will take its parameters::
  
              model = Model({y: a * x + b})
              constraint = Model.as_constraint(Eq(a, 1), model)
  
          ``constraint.params`` will be ``[a, b]`` instead of ``[a]``.
  
          :param constraint: An ``Expr``, a mapping or iterable of ``Expr``, or a
              ``Relational``.
          :param model: An instance of (a subclass of)
              :class:`~symfit.core.fit.BaseModel`.
          :param constraint_type: When ``constraint`` is not
              a :class:`~sympy.core.relational.Relational`, a
              :class:`~sympy.core.relational.Relational` has to be provided
              explicitly.
          :param kwargs: Any additional keyword arguments which will be passed on
              to the init method.
          """
          allowed_types = [sympy.Eq, sympy.Ge, sympy.Le]
  
          if isinstance(constraint, Relational):
              constraint_type = constraint.__class__
              constraint = constraint.lhs - constraint.rhs
  
          # Initiate the constraint model, in such a way that we take care
          # of any dependencies
          instance = cls.with_dependencies(constraint,
                                           dependency_model=model,
                                           **init_kwargs)
  
          # Check if the constraint_type is allowed, and flip the sign if needed
          if constraint_type not in allowed_types:
              raise ModelError(
                  'Only constraints of the type {} are allowed. A constraint'
                  ' of type {} was provided.'.format(allowed_types,
                                                     constraint_type)
              )
          elif constraint_type is sympy.Le:
              # We change this to a Ge and flip the sign
              instance = - instance
              constraint_type = sympy.Ge
  
          instance.constraint_type = constraint_type
  
          if len(instance.dependent_vars) != 1:
              raise ModelError('Only scalar models can be used as constraints.')
  
          # self.params has to be a subset of model.params
          if set(instance.params) <= set(model.params):
              instance.params = model.params
          else:
              raise ModelError('The parameters of ``constraint`` have to be a '
                               'subset of those of ``model``.')
  
          return instance