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

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

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

Solution:

    output = np.zeros(A.shape)
    for i in range(A.shape[0]):
        output[i] =  median_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_median_filter(A,size=size)
expect = np.array([
    [
        [0.78141144, 0.78141144, 0.64251554, 0.69554888, 0.64251554],
        [0.45800132, 0.74111387, 0.74111387, 0.74111387, 0.69554888],
        [0.2246344,  0.4269733,  0.55219084, 0.55219084, 0.45397657],
        [0.2246344,  0.38487986, 0.4269733,  0.55219084, 0.7264364 ],
        [0.08366183, 0.38487986, 0.15346239, 0.43945519, 0.55219084]
    ],
    [
        [0.72803114, 0.61553871, 0.56355775, 0.54231049, 0.3109029 ],
        [0.70631765, 0.70631765, 0.61553871, 0.56355775, 0.3109029 ],
        [0.70631765, 0.70631765, 0.61553871, 0.77465223, 0.77465223],
        [0.53101621, 0.53101621, 0.17058994, 0.32359305, 0.50987675],
        [0.53101621, 0.53101621, 0.17058994, 0.17058994, 0.32359305]
    ],
    [
        [0.83804647, 0.83804647, 0.67511118, 0.59591408, 0.17378608],
        [0.83804647, 0.5460935,  0.46040221, 0.45809764, 0.45809764],
        [0.5460935,  0.49930348, 0.23131078, 0.45809764, 0.59591408],
        [0.49930348, 0.23131078, 0.23131078, 0.46040221, 0.67501737],
        [0.21602811, 0.1936703,  0.21602811, 0.67501737, 0.87881997]
    ]
])

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