'Validate a given bounding box sequence against the given model (which
may be either a subclass of `~astropy.modeling.Model` or an instance
thereof, so long as the ``.inputs`` attribute is defined.
Currently this just checks that the bounding_box is either a 2-tuple
of lower and upper bounds for 1-D models, or an N-tuple of 2-tuples
for N-D models.
This also returns a normalized version of the bounding_box input to
ensure it is always an N-tuple (even for the 1-D case).'

@classmethod
def validate(cls, model, bounding_box):

    nd = model.n_inputs
    if (nd == 1):
        if ((not isiterable(bounding_box)) or (np.shape(bounding_box) not in ((2,), (1, 2)))):
            raise ValueError(u'Bounding    box    for    {0}    model    must    be    a    sequence    of    length    2    consisting    of    a    lower    and    upper    bound,    or    a    1-tuple    containing    such    a    sequence    as    its    sole    element.'.format(model.name))
        if (len(bounding_box) == 1):
            return cls((tuple(bounding_box[0]),))
        else:
            return cls(tuple(bounding_box))
    else:
        if ((not isiterable(bounding_box)) or (np.shape(bounding_box) != (nd, 2))):
            raise ValueError(u'Bounding    box    for    {0}    model    must    be    a    sequence    of    length    {1}    (the    number    of    model    inputs)    consisting    of    pairs    of    lower    and    upper    bounds    for    those    inputs    on    which    to    evaluate    the    model.'.format(model.name, nd))
        return cls((tuple(bounds) for bounds in bounding_box))
