code: def fraction_visited(source, sink, waypoint, msm):
      
  
      for_committors = committors([source], [sink], msm)
      cond_committors = conditional_committors(source, sink, waypoint, msm)
  
      if hasattr(msm, 'all_transmats_'):
          frac_visited = np.zeros((msm.n_states,))
          for i, tprob in enumerate(msm.all_transmats_):
              frac_visited[i] = _fraction_visited(source, sink, waypoint,
                                                  msm.transmat_, for_committors,
                                                  cond_committors)
          return np.median(frac_visited, axis=0)
  
      return _fraction_visited(source, sink, waypoint, msm.transmat_,
                               for_committors, cond_committors)
docs: Calculate the fraction of times a walker on `tprob` going from `sources`
      to `sinks` will travel through the set of states `waypoints` en route.
  
      Computes the conditional committors q^{ABC^+} and uses them to find the
      fraction of paths mentioned above.
  
      Note that in the notation of Dickson et. al. this computes h_c(A,B), with
          sources   = A
          sinks     = B
          waypoint  = C
  
      Parameters
      ----------
      source : int
          The index of the source state
      sink : int
          The index of the sink state
      waypoint : int
          The index of the intermediate state
      msm : msmbuilder.MarkovStateModel
          MSM to analyze.
  
      Returns
      -------
      fraction_visited : float
          The fraction of times a walker going from `sources` -> `sinks` stops
          by `waypoints` on its way.
  
      See Also
      --------
      msmbuilder.tpt.conditional_committors
          Calculate the probability of visiting a waypoint while on a path
          between a source and sink.
      msmbuilder.tpt.hub_scores : function
          Compute the 'hub score', the weighted fraction of visits for an
          entire network.
  
      References
      ----------
      .. [1] Dickson & Brooks (2012), J. Chem. Theory Comput., 8, 3044-3052.