<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def vizarray(x, cmap=None, scale=None, vmin=None, vmax=None, block_size=None):
 """Visualize a NumPy array using ipythonblocks."""

    if not (x.ndim == 2 or x.ndim == 1):
        raise TypeError('This function only works with 1 or 2 dimensional arrays')
    global _cmap, _scale, _vmin, _vmax, _block_size
    cmap = cmap if cmap is not None else _cmap
    scale = scale if scale is not None else _scale
    vmin = vmin if vmin is not None else _vmin
    vmax = vmax if vmax is not None else _vmax
    block_size = block_size if block_size is not None else _block_size
    base = x.base if x.base is not None else None
    data = x.copy()
    if scale:
        n = colors.Normalize(vmin=vmin, vmax=vmax)
        if base is not None:
            n.autoscale(base)
        data = n(data)
    if data.ndim == 1:
        rows = 1
        cols = data.shape[0]
        bg = BlockGrid(cols, rows, block_size=block_size)
        for col in range(cols):
            bg[0,col] = _value_to_color(data[col], cmap)
    elif data.ndim == 2:
        rows = data.shape[0]
        cols = data.shape[1]
        bg = BlockGrid(cols, rows, block_size=block_size)
        for row in range(rows):
            for col in range(cols):
                bg[row, col] = _value_to_color(data[row, col], cmap)
    return bg