'This method is used in `~astropy.modeling.Model.__call__` to ensure
that all the inputs to the model can be broadcast into compatible
shapes (if one or both of them are input as arrays), particularly if
there are more than one parameter sets. This also makes sure that (if
applicable) the units of the input will be compatible with the evaluate
method.'

def prepare_inputs(self, *inputs, **kwargs):

    model_set_axis = kwargs.pop(u'model_set_axis', None)
    equivalencies = kwargs.pop(u'equivalencies', None)
    if (model_set_axis is None):
        model_set_axis = self.model_set_axis
    n_models = len(self)
    params = [getattr(self, name) for name in self.param_names]
    inputs = [np.asanyarray(_input, dtype=float) for _input in inputs]
    _validate_input_shapes(inputs, self.inputs, n_models, model_set_axis, self.standard_broadcasting)
    if (self.input_units is not None):
        input_units_equivalencies = _combine_equivalency_dict(self.inputs, equivalencies, self.input_units_equivalencies)
        for i in range(len(inputs)):
            input_name = self.inputs[i]
            input_unit = self.input_units.get(input_name, None)
            if (input_unit is None):
                continue
            if isinstance(inputs[i], Quantity):
                if inputs[i].unit.is_equivalent(input_unit, equivalencies=input_units_equivalencies[input_name]):
                    if ((len(input_units_equivalencies) > 0) or self.input_units_strict):
                        inputs[i] = inputs[i].to(input_unit, equivalencies=input_units_equivalencies[input_name])
                elif (input_unit is dimensionless_unscaled):
                    raise UnitsError(u"Units    of    input    '{0}',    {1}    ({2}),    could    not    be    converted    to    required    dimensionless    input".format(self.inputs[i], inputs[i].unit, inputs[i].unit.physical_type))
                else:
                    raise UnitsError(u"Units    of    input    '{0}',    {1}    ({2}),    could    not    be    converted    to    required    input    units    of    {3}    ({4})".format(self.inputs[i], inputs[i].unit, inputs[i].unit.physical_type, input_unit, input_unit.physical_type))
            elif ((not self.input_units_allow_dimensionless) and (input_unit is not dimensionless_unscaled) and (input_unit is not None)):
                if np.any((inputs[i] != 0)):
                    raise UnitsError(u"Units    of    input    '{0}',    (dimensionless),    could    not    be    converted    to    required    input    units    of    {1}    ({2})".format(self.inputs[i], input_unit, input_unit.physical_type))
    if (n_models == 1):
        return _prepare_inputs_single_model(self, params, inputs, **kwargs)
    else:
        return _prepare_inputs_model_set(self, params, inputs, n_models, model_set_axis, **kwargs)
