code: def infer_warn_stats_info(
      stats_dtypes: List[Dict[str, StatDtype]],
      sds: Dict[str, Tuple[StatDtype, StatShape]],
      stepname: str,
  ) -> Tuple[
      List[Dict[str, StatDtype]], Dict[str, Tuple[StatDtype, StatShape]]
  ]:
      """Helper function to get `stats_dtypes` and `stats_dtypes_shapes` from either of them."""
      # Avoid side-effects on the original lists/dicts
      stats_dtypes = [d.copy() for d in stats_dtypes]
      sds = sds.copy()
      # Disallow specification of both attributes
      if stats_dtypes and sds:
          raise TypeError(
              "Only one of `stats_dtypes_shapes` or `stats_dtypes` must be specified."
              f" `{stepname}.stats_dtypes` should be removed."
          )
  
      # Infer one from the other
      if not sds and stats_dtypes:
          warnings.warn(
              f"`{stepname}.stats_dtypes` is deprecated."
              " Please update it to specify `stats_dtypes_shapes` instead.",
              DeprecationWarning,
          )
          if len(stats_dtypes) > 1:
              raise TypeError(
                  f"`{stepname}.stats_dtypes` must be a list containing at most one dict."
              )
          for sd in stats_dtypes:
              for sname, dtype in sd.items():
                  sds[sname] = (dtype, None)
      elif sds:
          stats_dtypes.append(
              {sname: dtype for sname, (dtype, _) in sds.items()}
          )
      return stats_dtypes, sds
  
imports: import warnings
  from abc import ABC, abstractmethod
  from enum import IntEnum, unique
  from typing import Any, Dict, Iterable, List, Mapping, Sequence, Tuple, Union
  import numpy
  from pytensor.graph.basic import Variable
  from pymc.blocking import PointType, StatDtype, StatsDict, StatShape, StatsType
  from pymc.model import modelcontext
label_desc: Use image node_id 1 for calling a global function with example usage: infer_warn_stats_info(stats_dtypes, sds, stepname) and returns: stats_dtypes,  sds