code: def _hits_python(
      G, max_iter=100, tol=1.0e-8, nstart=None, normalized=True
  ):
      if isinstance(G, nx.MultiGraph | nx.MultiDiGraph):
          raise Exception(
              "hits() not defined for graphs with multiedges."
          )
      if len(G) == 0:
          return {}, {}
      # choose fixed starting vector if not given
      if nstart is None:
          h = dict.fromkeys(G, 1.0 / G.number_of_nodes())
      else:
          h = nstart
          # normalize starting vector
          s = 1.0 / sum(h.values())
          for k in h:
              h[k] *= s
      for _ in range(
          max_iter
      ):  # power iteration: make up to max_iter iterations
          hlast = h
          h = dict.fromkeys(hlast.keys(), 0)
          a = dict.fromkeys(hlast.keys(), 0)
          # this "matrix multiply" looks odd because it is
          # doing a left multiply a^T=hlast^T*G
          for n in h:
              for nbr in G[n]:
                  a[nbr] += hlast[n] * G[n][nbr].get("weight", 1)
          # now multiply h=Ga
          for n in h:
              for nbr in G[n]:
                  h[n] += a[nbr] * G[n][nbr].get("weight", 1)
          # normalize vector
          s = 1.0 / max(h.values())
          for n in h:
              h[n] *= s
          # normalize vector
          s = 1.0 / max(a.values())
          for n in a:
              a[n] *= s
          # check convergence, l1 norm
          err = sum(abs(h[n] - hlast[n]) for n in h)
          if err < tol:
              break
      else:
          raise nx.PowerIterationFailedConvergence(max_iter)
      if normalized:
          s = 1.0 / sum(a.values())
          for n in a:
              a[n] *= s
          s = 1.0 / sum(h.values())
          for n in h:
              h[n] *= s
      return h, a
  
imports: import networkx
label_desc: Use image node_id 2 for calling a global function with example usage: _hits_python(G, max_iter, tol, nstart, normalized) and returns: h,  a, dict,  dict