code: def num_of_islands(grid):
      n = len(grid)
      if n == 0:
          return 0
      m = len(grid[0])
  
      islands = 0
      queue = deque()
      directions = [(-1, 0), (0, 1), (1, 0), (0, -1)]
  
      for i in range(n):
          for j in range(m):
              # search for an island
              if grid[i][j] == "1":
                  islands += 1
                  queue.append((i, j))
  
                  # BFS
                  while queue:
                      coord = queue.popleft()
                      x, y = coord
  
                      if grid[x][y] != "1":
                          continue
                      # delete the island
                      grid[x][y] = "0"
  
                      for direction in directions:
                          # calculate the next position
                          next_x, next_y = (
                              x + direction[0],
                              y + direction[1],
                          )
                          # check if the next position is valid
                          if (next_x < 0) or (next_x >= n):
                              continue
                          if (next_y < 0) or (next_y >= m):
                              continue
                          # save this position
                          queue.append((next_x, next_y))
  
      return islands
  
label_desc: Use image node_id 1 for calling a global function with example usage: num_of_islands(grid) and returns: islands, int