<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collage(imgs, size, padding=10, bg=COL_BLACK):
 """ Constructs a collage of same-sized images with specified padding. :param imgs: Array of images. Either 1d-array or 2d-array. :param size: (no. of rows, no. of cols) :param padding: Padding space between each image :param bg: Background color for the collage. Default: Black :return: New collage """

    # make 2d array
    if not isinstance(imgs[0], list):
        imgs = [imgs]

    h, w = imgs[0][0].shape[:2]
    nrows, ncols = size
    nr, nc = nrows * h + (nrows-1) * padding, ncols * w + (ncols-1) * padding

    res = np.ones((nr, nc, 3), dtype=np.uint8) * np.array(bg, dtype=np.uint8)

    for r in range(nrows):
        for c in range(ncols):
            img = imgs[r][c]

            if is_gray(img):
                img = gray3ch(img)

            rs = r * (h + padding)
            re = rs + h

            cs = c * (w + padding)
            ce = cs + w

            res[rs:re, cs:ce, :] = img

    return res