code: def model_to_graphviz(
      model=None,
      *,
      var_names: Optional[Iterable[VarName]] = None,
      formatting: str = "plain",
  ):
      """Produce a graphviz Digraph from a PyMC model.
  
      Requires graphviz, which may be installed most easily with
          conda install -c conda-forge python-graphviz
  
      Alternatively, you may install the `graphviz` binaries yourself,
      and then `pip install graphviz` to get the python bindings.  See
      http://graphviz.readthedocs.io/en/stable/manual.html
      for more information.
  
      Parameters
      ----------
      model : pm.Model
          The model to plot. Not required when called from inside a modelcontext.
      var_names : iterable of variable names, optional
          Subset of variables to be plotted that identify a subgraph with respect to the entire model graph
      formatting : str, optional
          one of { "plain" }
  
      Examples
      --------
      How to plot the graph of the model.
  
      .. code-block:: python
  
          import numpy as np
          from pymc import HalfCauchy, Model, Normal, model_to_graphviz
  
          J = 8
          y = np.array([28, 8, -3, 7, -1, 1, 18, 12])
          sigma = np.array([15, 10, 16, 11, 9, 11, 10, 18])
  
          with Model() as schools:
  
              eta = Normal("eta", 0, 1, shape=J)
              mu = Normal("mu", 0, sigma=1e6)
              tau = HalfCauchy("tau", 25)
  
              theta = mu + tau * eta
  
              obs = Normal("obs", theta, sigma=sigma, observed=y)
  
          model_to_graphviz(schools)
      """
      if "plain" not in formatting:
          raise ValueError(
              f"Unsupported formatting for graph nodes: '{formatting}'. See docstring."
          )
      if formatting != "plain":
          warnings.warn(
              "Formattings other than 'plain' are currently not supported.",
              UserWarning,
              stacklevel=2,
          )
      model = pm.modelcontext(model)
      return ModelGraph(model).make_graph(
          var_names=var_names, formatting=formatting
      )
  
imports: import warnings
  from collections import defaultdict
  from typing import Dict, Iterable, List, Optional, Sequence, Set
  from pytensor import function
  from pytensor.compile.sharedvalue import SharedVariable
  from pytensor.graph import Apply
  from pytensor.graph.basic import ancestors, walk
  from pytensor.scalar.basic import Cast
  from pytensor.tensor.elemwise import Elemwise
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.shape import Shape
  from pytensor.tensor.variable import TensorConstant, TensorVariable
  import pymc
  from pymc.util import VarName, get_default_varnames, get_var_name
label_desc: Use image node_id 3 for calling a global function with example usage: model_to_graphviz(model) and returns: ModelGraph