code: def is_valid(board: List[List[str]], max_size: int) -> bool:
      frontier, discovered = [], set()
      frontier.append((0, 0))
      while frontier:
          r, c = frontier.pop()
          if not (r, c) in discovered:
              discovered.add((r, c))
              directions = [(1, 0), (0, 1), (-1, 0), (0, -1)]
              for x, y in directions:
                  r_new = r + x
                  c_new = c + y
                  if (
                      r_new < 0
                      or r_new >= max_size
                      or c_new < 0
                      or c_new >= max_size
                  ):
                      continue
                  if board[r_new][c_new] == "G":
                      return True
                  if board[r_new][c_new] != "H":
                      frontier.append((r_new, c_new))
      return False
  
file_path: gym/gym/envs/toy_text/frozen_lake.py
imports: from contextlib import closing
  from io import StringIO
  from os import path
  from typing import List, Optional
  import numpy
  from gym import Env, logger, spaces, utils
  from gym.envs.toy_text.utils import categorical_sample
  from gym.error import DependencyNotInstalled
label_desc: Use image node_id 1 for calling a global function with example usage: is_valid(board, max_size) and returns: False, True