def __getitem__(self, key):
        """Retrieves the corresponding `DTypePolicy` by the string key.

        When there isn't an exact match, all the existing keys in the map
        will be treated as a regex and map against the input key again. When
        there are multiple matches for the regex, an `ValueError` will be
        raised. Returns `self.default_policy` if there isn't any match found.

        Args:
            key: String key to query a `DTypePolicy`.

        Returns:
            Corresponding `DTypePolicy` based on the query.
        """
        if key in self._policy_map:
            return self._policy_map[key]

        matching_keys = []
        for k in self._policy_map:
            if re.search(k, key):
                matching_keys.append(k)
        if len(matching_keys) > 1:
            raise ValueError(
                f"Path '{key}' matches multiple dtype policy "
                f"specification keys: {matching_keys}. Please make "
                "sure each path only matches at most "
                "one dtype policy specification key in the DTypePolicyMap."
            )
        elif len(matching_keys) == 1:
            return self._policy_map[matching_keys[0]]
        return self.default_policy
Retrieves the corresponding `DTypePolicy` by the string key.

        When there isn't an exact match, all the existing keys in the map
        will be treated as a regex and map against the input key again. When
        there are multiple matches for the regex, an `ValueError` will be
        raised. Returns `self.default_policy` if there isn't any match found.

        Args:
            key: String key to query a `DTypePolicy`.

        Returns:
            Corresponding `DTypePolicy` based on the query.
        
keras/src/dtype_policies/dtype_policy_map.py