code: def pad_block(block, block_size):
      
      unique_vals, unique_counts = np.unique(block, return_counts=True)
      most_frequent_value = unique_vals[np.argmax(unique_counts)]
      return np.pad(block,
                    tuple((0, desired_size - actual_size)
                          for desired_size, actual_size
                          in zip(block_size, block.shape)),
                    mode="constant", constant_values=most_frequent_value)
docs: Pad a block to block_size with its most frequent value