code: def left_right_ttcross_step(input_tensor, k, rank, row_idx, col_idx):
      """Compute the next (right) core's row indices by QR decomposition.
  
      For the current Tensor train core, we use the row indices and col indices to extract the entries from the input tensor
      and compute the next core's row indices by QR and max volume algorithm.
  
      Parameters
      ----------
  
      k: int
              the actual sweep iteration
      rank: list of int
              list of upper ranks (tensor_order)
      row_idx: list of list of int
              list of (tensor_order-1) of lists of left indices
      col_idx: list of list of int
              list of (tensor_order-1) of lists of right indices
  
      Returns
      -------
      next_row_idx : list of int
              the list of new row indices,
      fibers_list : list of slice
              the used fibers,
      Q_skeleton : matrix
              approximation of Q as product of Q and inverse of its maximum volume submatrix
      """
  
      tensor_shape = tl.shape(input_tensor)
      tensor_order = tl.ndim(input_tensor)
      fibers_list = []
  
      # Extract fibers according to the row and col indices
      for i in range(rank[k]):
          for j in range(rank[k + 1]):
              fiber = (
                  row_idx[k][i]
                  + (slice(None, None, None),)
                  + col_idx[k][j]
              )
              fibers_list.append(fiber)
      if k == 0:  # Is[k] will be empty
          idx = (slice(None, None, None),) + tuple(zip(*col_idx[k]))
      else:
          idx = [[] for i in range(tensor_order)]
          for lidx in row_idx[k]:
              for ridx in col_idx[k]:
                  for j, jj in enumerate(lidx):
                      idx[j].append(jj)
                  for j, jj in enumerate(ridx):
                      idx[len(lidx) + 1 + j].append(jj)
          idx[k] = slice(None, None, None)
          idx = tuple(idx)
  
      # Extract the core
      core = input_tensor[idx]
      # shape the core as a 3-tensor_order cube
      if k == 0:
          core = tl.reshape(
              core, (tensor_shape[k], rank[k], rank[k + 1])
          )
          core = tl.transpose(core, (1, 0, 2))
      else:
          core = tl.reshape(
              core, (rank[k], rank[k + 1], tensor_shape[k])
          )
          core = tl.transpose(core, (0, 2, 1))
  
      # merge r_k and n_k, get a matrix
      core = tl.reshape(core, (rank[k] * tensor_shape[k], rank[k + 1]))
  
      # Compute QR decomposition
      (Q, R) = tl.qr(core)
  
      # Maxvol
      (I, _) = maxvol(Q)
  
      # Retrive indices in folded tensor
      new_idx = [
          np.unravel_index(idx, [rank[k], tensor_shape[k]]) for idx in I
      ]  # First retrive idx in folded core
      next_row_idx = [
          row_idx[k][ic[0]] + (ic[1],) for ic in new_idx
      ]  # Then reconstruct the idx in the tensor
  
      return (next_row_idx, fibers_list)
  
imports: import tensorly
  from ...tt_tensor import tt_to_tensor
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: left_right_ttcross_step(input_tensor, k, rank, row_idx, col_idx) and returns: next_row_idx,  fibers_list