Specifying hierarchical Binomial model when individuals have varying numbers of trials?

So, I created an array, coin_range_lens, which is an array [30, 31, 33, 19, 40] with the lengths of trials for each of the 5 coins. This was my code,

import itertools
len_of_each_coin = [np.argwhere(coin_data_index == i).T[0] for i in range(5)]

def to_ranges(iterable):

    for mini_list in iterable:
        if type(mini_list) == np.ndarray:
            mini_list = mini_list.tolist()
        mini_list = sorted(set(mini_list))
        for key, group in itertools.groupby(enumerate(mini_list),
                                            lambda t: t[1] - t[0]):
            group = list(group)
            yield group[0][1], group[-1][1]

coin_ranges = list(to_ranges(len_of_each_coin))
coin_range_lens = [len(range(i[0], i[1])) for i in coin_ranges]

, but using coin_range_lens as n returns a Input dimension mis-match error.

coin_data is for me a flat array with all the trials of all the coins. How could the lengths vector n be as long as coin_data itself, junpenglao?

array([1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,
       0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0,
       0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0,
       0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0,
       0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1,
       1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0,
       0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1,
       0, 1, 1, 1])