Library: scipy==1.9.2 (Python 3.10, released 2022-10)

Problem: 
Complete the function that applies a maximum filter on batched images (batched in the first dimention), non specified parameters should use the default value

Starting code:
from scipy.ndimage import maximum_filter
import numpy as np 
def apply_maximum_filter(A: np.ndarray, size: int) -> np.ndarray:
    

Solution:

    output = np.zeros(A.shape)
    for i in range(A.shape[0]):
        output[i] =  maximum_filter(A[i], size=size)
    return output

Test:

A = np.array([[[7.81411439e-01, 1.12331105e-02, 9.39679607e-01, 6.42515536e-01,
         6.95548884e-01],
        [4.58001321e-01, 7.90049557e-01, 7.41113873e-01, 9.85894466e-03,
         4.53976568e-01],
        [2.24634401e-01, 4.26973301e-01, 8.91014236e-01, 8.23895514e-01,
         9.31046059e-01],
        [4.45855698e-02, 2.58723740e-02, 3.84879860e-01, 5.52190839e-01,
         8.30264909e-02],
        [9.15445530e-01, 8.36618255e-02, 4.39455188e-01, 1.53462390e-01,
         7.26436401e-01]],

       [[7.28031138e-01, 3.75117422e-01, 5.42310487e-01, 5.63557751e-01,
         2.57909701e-04],
        [7.50931873e-01, 6.15538706e-01, 9.05514875e-01, 8.48424138e-01,
         3.10902901e-01],
        [1.72613108e-01, 7.06317645e-01, 8.89355115e-01, 8.90701413e-02,
         9.28579120e-01],
        [9.80044173e-01, 1.67306937e-01, 1.69314197e-01, 5.09876755e-01,
         7.74652232e-01],
        [5.31016205e-01, 6.71446481e-01, 8.29882594e-02, 1.70589945e-01,
         3.23593050e-01]],

       [[8.38046468e-01, 7.96708042e-03, 9.28662972e-01, 6.75111182e-01,
         3.33247539e-02],
        [9.99455965e-01, 9.41123427e-01, 1.06977786e-01, 1.73786082e-01,
         5.95914076e-01],
        [5.46093501e-01, 4.99303483e-01, 4.60402210e-01, 4.75650259e-02,
         4.58097639e-01],
        [5.15319589e-01, 2.31310779e-01, 1.93670305e-01, 9.76320068e-01,
         8.78819966e-01],
        [1.09356481e-01, 2.16028113e-01, 1.67111833e-01, 9.65726787e-01,
         6.75017369e-01]]])
size=3
output = apply_maximum_filter(A,size=size)
expect = np.array([
    [
        [0.79004956, 0.93967961, 0.93967961, 0.93967961, 0.69554888],
        [0.79004956, 0.93967961, 0.93967961, 0.93967961, 0.93104606],
        [0.79004956, 0.89101424, 0.89101424, 0.93104606, 0.93104606],
        [0.91544553, 0.91544553, 0.89101424, 0.93104606, 0.93104606],
        [0.91544553, 0.91544553, 0.55219084, 0.7264364,  0.7264364 ]
    ],
    [
        [0.75093187, 0.90551488, 0.90551488, 0.90551488, 0.84842414],
        [0.75093187, 0.90551488, 0.90551488, 0.92857912, 0.92857912],
        [0.98004417, 0.98004417, 0.90551488, 0.92857912, 0.92857912],
        [0.98004417, 0.98004417, 0.88935511, 0.92857912, 0.92857912],
        [0.98004417, 0.98004417, 0.67144648, 0.77465223, 0.77465223]
    ],
    [
        [0.99945597, 0.99945597, 0.94112343, 0.92866297, 0.67511118],
        [0.99945597, 0.99945597, 0.94112343, 0.92866297, 0.67511118],
        [0.99945597, 0.99945597, 0.97632007, 0.97632007, 0.97632007],
        [0.5460935,  0.5460935,  0.97632007, 0.97632007, 0.97632007],
        [0.51531959, 0.51531959, 0.97632007, 0.97632007, 0.97632007]
    ]
])

assertion_value = np.allclose(output, expect)
assert assertion_value