code: def _check_symbol_mappings(df, exchanges, asset_exchange):
      """Check that there are no cases where multiple symbols resolve to the same
      asset at the same time in the same country.
  
      Parameters
      ----------
      df : pd.DataFrame
          The equity symbol mappings table.
      exchanges : pd.DataFrame
          The exchanges table.
      asset_exchange : pd.Series
          A series that maps sids to the exchange the asset is in.
  
      Raises
      ------
      ValueError
          Raised when there are ambiguous symbol mappings.
      """
      mappings = df.set_index("sid")[list(mapping_columns)].copy()
      mappings["country_code"] = exchanges["country_code"][
          asset_exchange.loc[df["sid"]]
      ].values
      ambigious = {}
  
      def check_intersections(persymbol):
          intersections = list(
              intersecting_ranges(
                  map(
                      from_tuple,
                      zip(persymbol.start_date, persymbol.end_date),
                  )
              )
          )
          if intersections:
              data = persymbol[["start_date", "end_date"]].astype(
                  "datetime64[ns]"
              )
              # indent the dataframe string, also compute this early because
              # ``persymbol`` is a view and ``astype`` doesn't copy the index
              # correctly in pandas 0.22
              msg_component = "\n  ".join(str(data).splitlines())
              ambigious[persymbol.name] = intersections, msg_component
  
      mappings.groupby(["symbol", "country_code"]).apply(
          check_intersections
      )
  
      if ambigious:
          raise ValueError(
              "Ambiguous ownership for %d symbol%s, multiple assets held the"
              " following symbols:\n%s"
              % (
                  len(ambigious),
                  "" if len(ambigious) == 1 else "s",
                  "\n".join(
                      "%s (%s):\n  intersections: %s\n  %s"
                      % (
                          symbol,
                          country_code,
                          tuple(map(_format_range, intersections)),
                          cs,
                      )
                      for (symbol, country_code), (
                          intersections,
                          cs,
                      ) in sorted(
                          ambigious.items(),
                          key=first,
                      )
                  ),
              )
          )
  
imports: from collections import namedtuple
  import re
  import numpy
  import pandas
  import sqlalchemy
  from toolz import first
  from zipline.errors import AssetDBVersionError
  from zipline.assets.asset_db_schema import ASSET_DB_VERSION, asset_db_table_names, asset_router, equities, equity_symbol_mappings, equity_supplementary_mappings, futures_contracts, exchanges, futures_root_symbols, metadata, version_info
  from zipline.utils.compat import ExitStack
  from zipline.utils.preprocess import preprocess
  from zipline.utils.range import from_tuple, intersecting_ranges
  from zipline.utils.sqlite_utils import coerce_string_to_eng
label_desc: Use image node_id 8 for calling a global function with example usage: _check_symbol_mappings(df, exchanges, asset_exchange) without return types