code: def _matrix_iterator(
      v,
      min_chunk_size,
      from_pos,
      to_pos,
      coldtypedic,
      transfer_features,
      verboseprint,
      logfile,
      hdf_key,
  ):
      ft_feature = None
      dt_unit = None
  
      # if hdf, find requested features
      if isinstance(v, pd.HDFStore):
          v_is_hdf = True
          rf = [
              transfer_features,
              CreatorFunction.c_input_features,
              CreatorFunction.s_input_features,
          ]
          rf = set(
              [
                  feature[:-2]
                  if feature.endswith("_s") or feature.endswith("_t")
                  else feature
                  for feature in _flatten(rf)
              ]
          )
      else:
          v_is_hdf = False
  
      if v_is_hdf:
          N = v.get_storer(hdf_key).nrows
      else:
          N = len(v)
  
      if to_pos is None:
          to_pos = N * (N - 1) / 2
  
      # assertions
      assert to_pos <= N * (N - 1) / 2, (
          "the given to_pos parameter is too large, "
          "{} > g.n*(g.n-1)/2={}".format(to_pos, N * (N - 1) / 2)
      )
  
      assert from_pos < N * (N - 1) / 2, (
          "the given from_pos argument is too large, "
          "{} (given) > {} (max)".format(
              from_pos, int(N * (N - 1) / 2) - 1
          )
      )
  
      assert from_pos < to_pos, "to_pos must be larger than from_pos"
  
      # cumulatively count the generated edges
      cum_edges = 0
  
      # iterate through matrix
      c = 0
      ei_list = []
      pos_array, n_steps = _pos_array(from_pos, to_pos, min_chunk_size)
      for from_pos, to_pos in pos_array:
          # measure time per iteration
          starttime = datetime.now()
  
          # print
          verboseprint(
              "# ====================================================="
          )
          verboseprint(
              "Iteration {} of {} ({:.2f}%)".format(
                  c + 1, n_steps, float(c + 1) / n_steps * 100
              )
          )
          c += 1
  
          # construct node indices
          sources_k, targets_k = _triu_indices(N, from_pos, to_pos)
  
          # unique indices of sources' & targets' union
          indices = _union_of_indices(N, sources_k, targets_k)
  
          # create triu_indices for subset of v
          sources_k, targets_k = _reduce_triu_indices(
              sources_k, targets_k, indices
          )
  
          # select subset of v
          if v_is_hdf:
              vi = v.select(hdf_key, where=indices, columns=rf)
          else:
              vi = v.iloc[indices]
  
          # return i'th selection
          ei = _select_and_return(
              vi,
              sources_k,
              targets_k,
              ft_feature,
              dt_unit,
              transfer_features,
              coldtypedic,
          )
          ei_list.append(ei)
  
          # print
          cum_edges += _count_edges(ei)
          timediff = datetime.now() - starttime
          verboseprint(
              " nr of edges:",
              [_count_edges(ei)],
              ", cum nr of edges:",
              [cum_edges],
          )
          verboseprint(" pos_interval:", [from_pos, to_pos])
          verboseprint(" nr of pairs (total):", [int(N * (N - 1) / 2)])
          verboseprint(" copied rs: {}".format(ei.columns.values))
          verboseprint(
              " computation time:",
              "\ts =",
              int(timediff.total_seconds()),
              "\tms =",
              str(timediff.microseconds / 1000.0)[:6],
              "\n",
          )
  
          # logging
          if logfile:
              with open(logfile, "a") as log:
                  print(
                      "0\t{}\t".format(len(sources_k)), end="", file=log
                  )
                  print(
                      "{}\t{:.3f}".format(
                          _count_edges(ei), timediff.total_seconds()
                      ),
                      file=log,
                  )
  
      # concat eik_list
      e = pd.concat(ei_list, ignore_index=True, copy=False)
  
      # set indices
      e.set_index(["s", "t"], inplace=True)
  
      return e
  
file_path: deepgraph/deepgraph/iterators_and_indexers.py
imports: from datetime import datetime
  from itertools import chain
  import numpy
  import pandas
  from deepgraph._triu_indices import _triu_indices, _union_of_indices, _reduce_triu_indices
  from deepgraph.connector_selector_implementations import _ft_connector, _ft_selector
  from deepgraph.connectors_and_selectors import CreatorFunction, Selector, Connector
  from deepgraph.utils import _flatten, _is_array_like, _merge_dicts
label_desc: Use image node_id 5 for calling a global function with example usage: _matrix_iterator(v, min_chunk_size, from_pos, to_pos, coldtypedic, transfer_features, verboseprint, logfile, hdf_key) and returns: e