code: def robust_init(stochclass, tries, *args, **kwds):
      
      # Find the direct parents
      stochs = [arg for arg in (list(args) + list(kwds.values()))
                if isinstance(arg.__class__, StochasticMeta)]
  
      # Find the extended parents
      parents = stochs
      for s in stochs:
          parents.extend(s.extended_parents)
  
      extended_parents = set(parents)
  
      # Select the parents with a random method.
      random_parents = [
          p for p in extended_parents if p.rseed is True and hasattr(
              p,
              'random')]
  
      for i in range(tries):
          try:
              return stochclass(*args, **kwds)
          except ZeroProbability:
              exc = sys.exc_info()
              for parent in random_parents:
                  try:
                      parent.random()
                  except:
                      six.reraise(*exc)
  
      six.reraise(*exc)
docs: Robust initialization of a Stochastic.
  
      If the evaluation of the log-probability returns a ZeroProbability
      error, due for example to a parent being outside of the support for
      this Stochastic, the values of parents are randomly sampled until
      a valid log-probability is obtained.
  
      If the log-probability is still not valid after `tries` attempts, the
      original ZeroProbability error is raised.
  
      :Parameters:
      stochclass : Stochastic, eg. Normal, Uniform, ...
        The Stochastic distribution to instantiate.
      tries : int
        Maximum number of times parents will be sampled.
      *args, **kwds
        Positional and keyword arguments to declare the Stochastic variable.
  
      :Example:
      >>> lower = pymc.Uniform('lower', 0., 2., value=1.5, rseed=True)
      >>> pymc.robust_init(pymc.Uniform, 100, 'data', lower=lower, upper=5, value=[1,2,3,4], observed=True)