code: def _prepare_tiles(
      tiles: Optional[Union[str, dict]]
  ) -> Optional[dict]:
      if isinstance(tiles, str):
          return {
              OPTIONS_MAPTILES_KIND: TILES_RASTER_ZXY,
              OPTIONS_MAPTILES_URL: tiles,
          }
  
      if isinstance(tiles, dict):
          if tiles.get(MAPTILES_KIND) == TILES_RASTER_ZXY:
              return {
                  OPTIONS_MAPTILES_KIND: TILES_RASTER_ZXY,
                  OPTIONS_MAPTILES_URL: tiles[MAPTILES_URL],
                  OPTIONS_MAPTILES_ATTRIBUTION: tiles[
                      MAPTILES_ATTRIBUTION
                  ],
                  OPTIONS_MAPTILES_MIN_ZOOM: tiles[MAPTILES_MIN_ZOOM],
                  OPTIONS_MAPTILES_MAX_ZOOM: tiles[MAPTILES_MAX_ZOOM],
              }
          elif tiles.get(MAPTILES_KIND) == TILES_VECTOR_LETS_PLOT:
              return {
                  OPTIONS_MAPTILES_KIND: TILES_VECTOR_LETS_PLOT,
                  OPTIONS_MAPTILES_URL: tiles[MAPTILES_URL],
                  OPTIONS_MAPTILES_THEME: tiles[MAPTILES_THEME],
                  OPTIONS_MAPTILES_ATTRIBUTION: tiles[
                      MAPTILES_ATTRIBUTION
                  ],
              }
          elif tiles.get(MAPTILES_KIND) == TILES_SOLID:
              return {
                  OPTIONS_MAPTILES_KIND: TILES_SOLID,
                  OPTIONS_MAPTILES_FILL_COLOR: tiles[
                      MAPTILES_SOLID_FILL_COLOR
                  ],
              }
          elif tiles.get(MAPTILES_KIND) == TILES_CHESSBOARD:
              return {OPTIONS_MAPTILES_KIND: TILES_CHESSBOARD}
          else:
              raise ValueError(
                  "Unsupported 'tiles' kind: "
                  + tiles.get(MAPTILES_KIND)
              )
  
      if tiles is not None:
          raise ValueError(
              "Unsupported 'tiles' parameter type: " + type(tiles)
          )
  
      # tiles are not set for this livemap - try to get global tiles config
      if has_global_value(MAPTILES_KIND):
          if not has_global_value(MAPTILES_URL):
              raise ValueError("URL for tiles service is not set")
  
          if get_global_val(MAPTILES_KIND) == TILES_RASTER_ZXY:
              return {
                  OPTIONS_MAPTILES_KIND: TILES_RASTER_ZXY,
                  OPTIONS_MAPTILES_URL: get_global_val(MAPTILES_URL),
                  OPTIONS_MAPTILES_ATTRIBUTION: get_global_val(
                      MAPTILES_ATTRIBUTION
                  )
                  if has_global_value(MAPTILES_ATTRIBUTION)
                  else None,
                  OPTIONS_MAPTILES_MIN_ZOOM: get_global_val(
                      MAPTILES_MIN_ZOOM
                  )
                  if has_global_value(MAPTILES_MIN_ZOOM)
                  else None,
                  OPTIONS_MAPTILES_MAX_ZOOM: get_global_val(
                      MAPTILES_MAX_ZOOM
                  )
                  if has_global_value(MAPTILES_MAX_ZOOM)
                  else None,
              }
  
          if get_global_val(MAPTILES_KIND) == TILES_VECTOR_LETS_PLOT:
              return {
                  OPTIONS_MAPTILES_KIND: TILES_VECTOR_LETS_PLOT,
                  OPTIONS_MAPTILES_URL: get_global_val(MAPTILES_URL),
                  OPTIONS_MAPTILES_THEME: get_global_val(MAPTILES_THEME)
                  if has_global_value(MAPTILES_THEME)
                  else None,
                  OPTIONS_MAPTILES_ATTRIBUTION: get_global_val(
                      MAPTILES_ATTRIBUTION
                  )
                  if has_global_value(MAPTILES_ATTRIBUTION)
                  else None,
              }
  
          if get_global_val(MAPTILES_KIND) == TILES_SOLID:
              return {
                  OPTIONS_MAPTILES_KIND: TILES_SOLID,
                  OPTIONS_MAPTILES_FILL_COLOR: get_global_val(
                      MAPTILES_SOLID_FILL_COLOR
                  ),
              }
  
      raise ValueError("Tile provider is not set.")
  
file_path: lets-plot/python-package/lets_plot/plot/geom_livemap_.py
imports: from enum import Enum
  from typing import Union, Optional, List
  from lets_plot._global_settings import MAPTILES_KIND, MAPTILES_URL, MAPTILES_THEME, MAPTILES_ATTRIBUTION, GEOCODING_PROVIDER_URL, GEOCODING_ROUTE, TILES_RASTER_ZXY, TILES_VECTOR_LETS_PLOT, MAPTILES_MIN_ZOOM, MAPTILES_MAX_ZOOM, TILES_SOLID, MAPTILES_SOLID_FILL_COLOR, TILES_CHESSBOARD
  from lets_plot._global_settings import has_global_value, get_global_val
  from .geom import _geom
label_desc: Use image node_id 3 for calling a global function with example usage: _prepare_tiles(tiles) and returns: dict, dict, dict, dict, dict, dict, dict, dict