code: def _prepare_location(
      location: Union[str, Geocodes, List[float], DataFrame]
  ) -> Optional[dict]:
      if location is None:
          return None
  
      value = location
      if isinstance(location, Geocodes):
          kind = RegionKind.region_ids
          value = location.unique_ids()
  
      elif isinstance(location, str):
          kind = RegionKind.region_name
  
      elif isinstance(location, list):
          if len(location) == 0 or len(location) % 2 != 0:
              raise ValueError(LOCATION_LIST_ERROR_MESSAGE)
          kind = RegionKind.coordinates
  
      elif isinstance(location, DataFrame):
          if not LOCATION_COORDINATE_COLUMNS.issubset(
              location.columns
          ) and not LOCATION_RECTANGLE_COLUMNS.issubset(
              location.columns
          ):
              raise ValueError(LOCATION_DATAFRAME_ERROR_MESSAGE)
          kind = RegionKind.data_frame
  
      else:
          raise ValueError("Wrong location type: " + location.__str__())
  
      return {"type": kind.value, "data": value}
  
file_path: lets-plot/python-package/lets_plot/geo_data/livemap_helper.py
imports: from enum import Enum
  from typing import Union, Optional, List
  from pandas import DataFrame
  from .geocodes import Geocodes
label_desc: Use image node_id 2 for calling a global function with example usage: _prepare_location(location) and returns: dict, None