How would you write a function that calculates the number of mines adjacent to each cell in a minesweeper board?

Free for the first 3 answer contributors

Interview question asked to Machine Learning Engineers and Data Scientists interviewing at Bolt, Flexport, Bumble and others: How would you write a function that calculates the number of mines adjacent to each cell in a minesweeper board?.