docstr: Perform initial imputation for input `X`.
  
  Parameters
  ----------
  X : ndarray, shape (n_samples, n_features)
      Input data, where `n_samples` is the number of samples and
      `n_features` is the number of features.
  
  in_fit : bool, default=False
      Whether function is called in :meth:`fit`.
  
  Returns
  -------
  Xt : ndarray, shape (n_samples, n_features)
      Input data, where `n_samples` is the number of samples and
      `n_features` is the number of features.
  
  X_filled : ndarray, shape (n_samples, n_features)
      Input data with the most recent imputations.
  
  mask_missing_values : ndarray, shape (n_samples, n_features)
      Input data's missing indicator matrix, where `n_samples` is the
      number of samples and `n_features` is the number of features.
  
  X_missing_mask : ndarray, shape (n_samples, n_features)
      Input data's mask matrix indicating missing datapoints, where
      `n_samples` is the number of samples and `n_features` is the
      number of features.
docstr_tok: ["Perform","initial","imputation","for","input","`","X","`",".","Parameters","--","--","--","--","--","X",":","ndarray",",","shape","(","n_samples",",","n_features",")","Input","data",",","where","`","n_samples","`","is","the","number","of","samples","and","`","n_features","`","is","the","number","of","features",".","in_fit",":","bool",",","default=False","Whether","function","is","called","in",":","meth",":","`","fit","`",".","Returns","--","--","--","-","Xt",":","ndarray",",","shape","(","n_samples",",","n_features",")","Input","data",",","where","`","n_samples","`","is","the","number","of","samples","and","`","n_features","`","is","the","number","of","features",".","X_filled",":","ndarray",",","shape","(","n_samples",",","n_features",")","Input","data","with","the","most","recent","imputations",".","mask_missing_values",":","ndarray",",","shape","(","n_samples",",","n_features",")","Input","data","'s","missing","indicator","matrix",",","where","`","n_samples","`","is","the","number","of","samples","and","`","n_features","`","is","the","number","of","features",".","X_missing_mask",":","ndarray",",","shape","(","n_samples",",","n_features",")","Input","data","'s","mask","matrix","indicating","missing","datapoints",",","where","`","n_samples","`","is","the","number","of","samples","and","`","n_features","`","is","the","number","of","features","."]
code: def _initial_imputation(self, X, in_fit=False):
      """Perform initial imputation for input `X`.
  
      Parameters
      ----------
      X : ndarray, shape (n_samples, n_features)
          Input data, where `n_samples` is the number of samples and
          `n_features` is the number of features.
  
      in_fit : bool, default=False
          Whether function is called in :meth:`fit`.
  
      Returns
      -------
      Xt : ndarray, shape (n_samples, n_features)
          Input data, where `n_samples` is the number of samples and
          `n_features` is the number of features.
  
      X_filled : ndarray, shape (n_samples, n_features)
          Input data with the most recent imputations.
  
      mask_missing_values : ndarray, shape (n_samples, n_features)
          Input data's missing indicator matrix, where `n_samples` is the
          number of samples and `n_features` is the number of features.
  
      X_missing_mask : ndarray, shape (n_samples, n_features)
          Input data's mask matrix indicating missing datapoints, where
          `n_samples` is the number of samples and `n_features` is the
          number of features.
      """
      if is_scalar_nan(self.missing_values):
          force_all_finite = "allow-nan"
      else:
          force_all_finite = True
  
      X = self._validate_data(
          X,
          dtype=FLOAT_DTYPES,
          order="F",
          reset=in_fit,
          force_all_finite=force_all_finite,
      )
      _check_inputs_dtype(X, self.missing_values)
  
      X_missing_mask = _get_mask(X, self.missing_values)
      mask_missing_values = X_missing_mask.copy()
      categorical_indices = sorted(self.categorical_indices) or []
      num_indices = [
          i for i in range(X.shape[1]) if i not in categorical_indices
      ]
      if self.initial_imputer_ is None:
          self.initial_imputer_ = ColumnTransformer(
              [
                  (
                      "num_imputer",
                      SimpleImputer(
                          missing_values=self.missing_values,
                          strategy=self.num_initial_strategy,
                      ),
                      num_indices,
                  ),
                  (
                      "cat_imputer",
                      SimpleImputer(
                          missing_values=self.missing_values,
                          strategy=self.cat_initial_strategy,
                      ),
                      categorical_indices,
                  ),
              ],
              remainder="passthrough",
              n_jobs=1,
          )
          X_filled = self.initial_imputer_.fit_transform(X)
      else:
          X_filled = self.initial_imputer_.transform(X)
  
      reorder_indices_mapping = {
          **{v: i for i, v in enumerate(num_indices)},
          **{
              v: i + len(num_indices) - 1
              for i, v in enumerate(categorical_indices)
          },
      }
      reorder_indices = [
          reorder_indices_mapping[i]
          for i in range(len(reorder_indices_mapping))
      ]
      X_filled = X_filled[:, reorder_indices]
  
      combined_statistics = np.zeros(X.shape[1])
      # Use getattr as the imputers may not have been fitted if there have
      # been no columns with the required dtype
      num_statistics = list(
          getattr(
              self.initial_imputer_.named_transformers_["num_imputer"],
              "statistics_",
              [],
          )
      )
      cat_statistics = list(
          getattr(
              self.initial_imputer_.named_transformers_["cat_imputer"],
              "statistics_",
              [],
          )
      )
      for i in range(len(combined_statistics)):
          if i in categorical_indices:
              combined_statistics[i] = cat_statistics.pop(0)
          else:
              combined_statistics[i] = num_statistics.pop(0)
  
      valid_mask = np.flatnonzero(
          np.logical_not(np.isnan(combined_statistics))
      )
      Xt = X[:, valid_mask]
      mask_missing_values = mask_missing_values[:, valid_mask]
  
      return Xt, X_filled, mask_missing_values, X_missing_mask
  
imports: from __future__ import annotations
  import warnings
  from time import time
  from typing import List, Optional
  import numpy
  import pandas
  from sklearn.base import BaseEstimator, clone
  from sklearn.compose import ColumnTransformer
  from sklearn.dummy import DummyClassifier
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.experimental import enable_iterative_imputer
  from sklearn.impute import IterativeImputer
  from sklearn.impute import SimpleImputer
  from sklearn.impute._iterative import FLOAT_DTYPES, _check_inputs_dtype, _get_mask, _ImputerTriplet, _safe_indexing, is_scalar_nan, stats
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import OneHotEncoder
  from sklearn.preprocessing import OrdinalEncoder
  from sklearn.utils import check_random_state
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 2 for calling the IterativeImputer obj's underlying member method code with example usage: obj._initial_imputation(X, in_fit) and returns: Xt,  X_filled,  mask_missing_values,  X_missing_mask