code: def _update_submatrix(full, sub, sub_inv, p, h, v):
      """Update submatrix and its inverse.
  
      sub_inv is the inverse of the submatrix of "full" obtained by removing
      the p-th row and column.
  
      sub_inv is modified in-place. After execution of this function, it contains
      the inverse of the submatrix of "full" obtained by removing the n+1-th row
      and column.
  
      This computation is based on the Sherman-Woodbury-Morrison identity.
  
      """
      n = p - 1
      v[: n + 1] = full[: n + 1, n]
      v[n + 1 :] = full[n + 2 :, n]
      h[: n + 1] = full[n, : n + 1]
      h[n + 1 :] = full[n, n + 2 :]
  
      # change row: first usage of SWM identity
      coln = sub_inv[:, n : n + 1]  # 2d array, useful for sub_inv below
      V = h - sub[n, :]
      coln = coln / (1.0 + np.dot(V, coln))
      # The following line is equivalent to
      # sub_inv -= np.outer(coln, np.dot(V, sub_inv))
      sub_inv -= np.dot(coln, np.dot(V, sub_inv)[np.newaxis, :])
      sub[n, :] = h
  
      # change column: second usage of SWM identity
      rown = sub_inv[n : n + 1, :]  # 2d array, useful for sub_inv below
      U = v - sub[:, n]
      rown = rown / (1.0 + np.dot(rown, U))
      # The following line is equivalent to (but faster)
      # sub_inv -= np.outer(np.dot(sub_inv, U), rown)
      sub_inv -= np.dot(np.dot(sub_inv, U)[:, np.newaxis], rown)
      sub[:, n] = v  # equivalent to sub[n, :] += U
  
      # Make sub_inv symmetric (overcome some numerical limitations)
      sub_inv += sub_inv.T.copy()
      sub_inv /= 2.0
  
imports: import collections.abc
  import itertools
  import operator
  import warnings
  import numpy
  import scipy.linalg
  from joblib import Memory, Parallel, delayed
  from sklearn.base import BaseEstimator
  from sklearn.covariance import empirical_covariance
  from sklearn.model_selection import check_cv
  from sklearn.utils.extmath import fast_logdet
  from .._utils import CacheMixin, logger
  from .._utils.extmath import is_spd
label_desc: Use image node_id 2 for calling a global function with example usage: _update_submatrix(full, sub, sub_inv, p, h, v) without return types