Reshape a rank 4 array to be rank 2, where each column of block_width is
    a filter, and each row of block height is an input channel. For example:

    [[[[ 11,  21,  31,  41],
       [ 51,  61,  71,  81],
       [ 91, 101, 111, 121]],
      [[ 12,  22,  32,  42],
       [ 52,  62,  72,  82],
       [ 92, 102, 112, 122]],
      [[ 13,  23,  33,  43],
       [ 53,  63,  73,  83],
       [ 93, 103, 113, 123]]],
     [[[ 14,  24,  34,  44],
       [ 54,  64,  74,  84],
       [ 94, 104, 114, 124]],
      [[ 15,  25,  35,  45],
       [ 55,  65,  75,  85],
       [ 95, 105, 115, 125]],
      [[ 16,  26,  36,  46],
       [ 56,  66,  76,  86],
       [ 96, 106, 116, 126]]],
     [[[ 17,  27,  37,  47],
       [ 57,  67,  77,  87],
       [ 97, 107, 117, 127]],
      [[ 18,  28,  38,  48],
       [ 58,  68,  78,  88],
       [ 98, 108, 118, 128]],
      [[ 19,  29,  39,  49],
       [ 59,  69,  79,  89],
       [ 99, 109, 119, 129]]]]

       should be reshaped to:

       [[ 11,  12,  13,  21,  22,  23,  31,  32,  33,  41,  42,  43],
        [ 14,  15,  16,  24,  25,  26,  34,  35,  36,  44,  45,  46],
        [ 17,  18,  19,  27,  28,  29,  37,  38,  39,  47,  48,  49],
        [ 51,  52,  53,  61,  62,  63,  71,  72,  73,  81,  82,  83],
        [ 54,  55,  56,  64,  65,  66,  74,  75,  76,  84,  85,  86],
        [ 57,  58,  59,  67,  68,  69,  77,  78,  79,  87,  88,  89],
        [ 91,  92,  93, 101, 102, 103, 111, 112, 113, 121, 122, 123],
        [ 94,  95,  96, 104, 105, 106, 114, 115, 116, 124, 125, 126],
        [ 97,  98,  99, 107, 108, 109, 117, 118, 119, 127, 128, 129]]

def _reshape_conv_array(self, array, section_height, image_width):
    '''Reshape a rank 4 array to be rank 2, where each column of block_width is
    a filter, and each row of block height is an input channel. For example:

    [[[[ 11,  21,  31,  41],
       [ 51,  61,  71,  81],
       [ 91, 101, 111, 121]],
      [[ 12,  22,  32,  42],
       [ 52,  62,  72,  82],
       [ 92, 102, 112, 122]],
      [[ 13,  23,  33,  43],
       [ 53,  63,  73,  83],
       [ 93, 103, 113, 123]]],
     [[[ 14,  24,  34,  44],
       [ 54,  64,  74,  84],
       [ 94, 104, 114, 124]],
      [[ 15,  25,  35,  45],
       [ 55,  65,  75,  85],
       [ 95, 105, 115, 125]],
      [[ 16,  26,  36,  46],
       [ 56,  66,  76,  86],
       [ 96, 106, 116, 126]]],
     [[[ 17,  27,  37,  47],
       [ 57,  67,  77,  87],
       [ 97, 107, 117, 127]],
      [[ 18,  28,  38,  48],
       [ 58,  68,  78,  88],
       [ 98, 108, 118, 128]],
      [[ 19,  29,  39,  49],
       [ 59,  69,  79,  89],
       [ 99, 109, 119, 129]]]]

       should be reshaped to:

       [[ 11,  12,  13,  21,  22,  23,  31,  32,  33,  41,  42,  43],
        [ 14,  15,  16,  24,  25,  26,  34,  35,  36,  44,  45,  46],
        [ 17,  18,  19,  27,  28,  29,  37,  38,  39,  47,  48,  49],
        [ 51,  52,  53,  61,  62,  63,  71,  72,  73,  81,  82,  83],
        [ 54,  55,  56,  64,  65,  66,  74,  75,  76,  84,  85,  86],
        [ 57,  58,  59,  67,  68,  69,  77,  78,  79,  87,  88,  89],
        [ 91,  92,  93, 101, 102, 103, 111, 112, 113, 121, 122, 123],
        [ 94,  95,  96, 104, 105, 106, 114, 115, 116, 124, 125, 126],
        [ 97,  98,  99, 107, 108, 109, 117, 118, 119, 127, 128, 129]]
    '''

    # E.g. [100, 24, 24, 10]: this shouldn't be reshaped like normal.
    if array.shape[1] == array.shape[2] and array.shape[0] != array.shape[1]:
      array = np.rollaxis(np.rollaxis(array, 2), 2)

    block_height, block_width, in_channels = array.shape[:3]
    rows = []

    max_element_count = section_height * int(image_width / MIN_SQUARE_SIZE)
    element_count = 0

    for i in range(in_channels):
      rows.append(array[:, :, i, :].reshape(block_height, -1, order='F'))

      # This line should be left in this position. Gives it one extra row.
      if element_count >= max_element_count and not self.config['show_all']:
        break

      element_count += block_height * in_channels * block_width

    return np.vstack(rows)