code: def str_for_model(
      model: Model,
      formatting: str = "plain",
      include_params: bool = True,
  ) -> str:
      """Make a human-readable string representation of Model, listing all random variables
      and their distributions, optionally including parameter values."""
  
      kwargs = dict(
          formatting=formatting, include_params=include_params
      )
      free_rv_reprs = [
          str_for_dist(dist, **kwargs) for dist in model.free_RVs
      ]
      observed_rv_reprs = [
          str_for_dist(rv, **kwargs) for rv in model.observed_RVs
      ]
      det_reprs = [
          str_for_potential_or_deterministic(
              dist, **kwargs, dist_name="Deterministic"
          )
          for dist in model.deterministics
      ]
      potential_reprs = [
          str_for_potential_or_deterministic(
              pot, **kwargs, dist_name="Potential"
          )
          for pot in model.potentials
      ]
  
      var_reprs = (
          free_rv_reprs
          + det_reprs
          + observed_rv_reprs
          + potential_reprs
      )
  
      if not var_reprs:
          return ""
      if "latex" in formatting:
          var_reprs = [
              var_repr.replace(r"\sim", r"&\sim &").strip("$")
              for var_repr in var_reprs
              if var_repr is not None
          ]
          return r"""$$
              \begin{{array}}{{rcl}}
              {}
              \end{{array}}
              $$""".format(
              "\\\\".join(var_reprs)
          )
      else:
          # align vars on their ~
          names = [s[: s.index("~") - 1] for s in var_reprs]
          distrs = [s[s.index("~") + 2 :] for s in var_reprs]
          maxlen = str(max(len(x) for x in names))
          var_reprs = [
              ("{name:>" + maxlen + "} ~ {distr}").format(
                  name=n, distr=d
              )
              for n, d in zip(names, distrs)
          ]
          return "\n".join(var_reprs)
  
file_path: pymc/pymc/printing.py
imports: from typing import Union
  from pytensor.compile import SharedVariable
  from pytensor.graph.basic import Constant, walk
  from pytensor.tensor.basic import TensorVariable, Variable
  from pytensor.tensor.elemwise import DimShuffle
  from pytensor.tensor.random.basic import RandomVariable
  from pytensor.tensor.random.var import RandomGeneratorSharedVariable, RandomStateSharedVariable
  from pymc.model import Model
label_desc: Use image node_id 2 for calling a global function with example usage: str_for_model(model, formatting, include_params) and returns: str, str, str