code: def _get_merged_translations(
      theme_dirs: Sequence[str], locales_dir: str, locale: Locale
  ) -> Translations | None:
      merged_translations: Translations | None = None
  
      log.debug(f"Looking for translations for locale '{locale}'")
      if locale.territory:
          locale_str = f"{locale.language}_{locale.territory}"
      else:
          locale_str = locale.language
      for theme_dir in reversed(theme_dirs):
          dirname = os.path.join(theme_dir, locales_dir)
          translations = Translations.load(dirname, [locale_str])
  
          if type(translations) is NullTranslations:
              log.debug(f"No translations found here: '{dirname}'")
              continue
          if TYPE_CHECKING:
              assert isinstance(translations, Translations)
  
          log.debug(f"Translations found here: '{dirname}'")
          if merged_translations is None:
              merged_translations = translations
          else:
              merged_translations.merge(translations)
  
      return merged_translations
  
file_path: mkdocs/mkdocs/localization.py
imports: from __future__ import annotations
  import logging
  import os
  from typing import TYPE_CHECKING, Sequence
  from jinja2.ext import Extension, InternationalizationExtension
  from mkdocs.config.base import ValidationError
label_desc: Use image node_id 3 for calling a global function with example usage: _get_merged_translations(theme_dirs, locales_dir, locale) and returns: merged_translations