def infer_type(data):
    if isinstance(data, (type(None), numbers.Number)):
        return 'scalar'
    if isinstance(data, SummaryStats):
        return 'summarystats'
    if hasattr(data, "__len__"):
        data = [x for x in data if x is not None]
        if len(data) == 0 or isinstance(data[0], numbers.Number):
            return 'distribution_scalar'
        if isinstance(data[0], SummaryStats):
            return 'distribution_summarystats'
        raise TypeError(
            "{} is not a valid input. It should be a number, a SummaryStats "
            "object, or None".format(data[0]))
    raise TypeError(
        "{} is not a valid input. It should be a number, a SummaryStats "
        "object, or a list".format(data))