code: def clone_model(model: Model) -> Model:
      """Clone a PyMC model.
  
      Recreates a PyMC model with clones of the original variables.
      Shared variables will point to the same container but be otherwise different objects.
      Constants are not cloned.
  
  
      Examples
      --------
      .. code-block:: python
  
          import pymc as pm
          from pymc.model.fgraph import clone_model
  
          with pm.Model() as m:
              p = pm.Beta("p", 1, 1)
              x = pm.Bernoulli("x", p=p, shape=(3,))
  
          with clone_model(m) as clone_m:
              # Access cloned variables by name
              clone_x = clone_m["x"]
  
              # z will be part of clone_m but not m
              z = pm.Deterministic("z", clone_x + 1)
  
      """
      return model_from_fgraph(fgraph_from_model(model)[0])
  
imports: from copy import copy
  from typing import Dict, Optional, Tuple
  import pytensor
  from pytensor import Variable, shared
  from pytensor.compile import SharedVariable
  from pytensor.graph import Apply, FunctionGraph, Op, node_rewriter
  from pytensor.graph.rewriting.basic import out2in
  from pytensor.scalar import Identity
  from pytensor.tensor.elemwise import Elemwise
  from pytensor.tensor.sharedvar import ScalarSharedVariable
  from pymc.logprob.transforms import Transform
  from pymc.model.core import Model
  from pymc.pytensorf import StringType, find_rng_nodes, toposort_replace
label_desc: Use image node_id 5 for calling a global function with example usage: clone_model(model) and returns: model_from_fgraph