code: def warn_treedepth(
      idata: arviz.InferenceData,
  ) -> List[SamplerWarning]:
      """Checks sampler stats and creates a list of warnings about tree depth."""
      sampler_stats = idata.get("sample_stats", None)
      if sampler_stats is None:
          return []
  
      rmtd = sampler_stats.get("reached_max_treedepth", None)
      if rmtd is None:
          return []
  
      warnings = []
      for c in rmtd.chain:
          if sum(rmtd.sel(chain=c)) / rmtd.sizes["draw"] > 0.05:
              warnings.append(
                  SamplerWarning(
                      WarningType.TREEDEPTH,
                      f"Chain {int(c)} reached the maximum tree depth."
                      " Increase `max_treedepth`, increase `target_accept` or reparameterize.",
                      "warn",
                  )
              )
      return warnings
  
file_path: pymc/pymc/stats/convergence.py
imports: import dataclasses
  import enum
  import logging
  from typing import Any, Dict, List, Optional, Sequence
  import arviz
  from pymc.util import get_untransformed_name, is_transformed_name
label_desc: Use image node_id 3 for calling a global function with example usage: warn_treedepth(idata) and returns: warnings, list, list