code: def _logistic_residualize(
      X: NDArray[(Any, Any), Float],
      C: NDArray[(Any, Any), Float],
      Y_mask: NDArray[(Any, Any), bool],
      gamma: NDArray[(Any, Any), Float],
      inv_CtGammaC: NDArray[(Any, Any), Float],
  ) -> NDArray[(Any, Any), Float]:
      """
      Residualize the genotype vectors given the null model predictions.
      X_res = X - C(C.T gamma C)^-1 C.T gamma X
      """
      X_hat = gwas_fx._einsum(
          "ic,pcd,ds,sp,sg,sp->igp",
          C,
          inv_CtGammaC,
          C.T,
          gamma,
          X,
          Y_mask,
      )
      return X[:, :, None] - X_hat
  
imports: from pyspark.sql.types import ArrayType, BooleanType, StringType, StructField, DataType, StructType
  from typing import Any, List, Optional, Dict, Union
  import pandas
  import numpy
  from pyspark.sql import DataFrame, SparkSession
  import statsmodels.api
  from dataclasses import dataclass
  from typeguard import typechecked
  from nptyping import Float, NDArray, Int32
  from scipy import stats
  import opt_einsum
  from .None import functions
  from .None import approx_firth
  from .functions import _VALUES_COLUMN_NAME, _get_indices_to_drop
  from ..wgr.wgr_functions import reshape_for_gwas
label_desc: Use image node_id 6 for calling a global function with example usage: _logistic_residualize(X, C, Y_mask, gamma, inv_CtGammaC) and returns: unknown