code: def test_metrics_with_missing_values_exo():
      """Checks that metrics produced with data WITH exogenous variables but
      having missing data in CV and Test split does not produce NA values.
      i.e. the metrics are computed using the imputed values.
      """
  
      # Load data and simulate missing values ----
      data = get_data("uschange")
      target = "Consumption"
  
      remove_n = int(0.4 * len(data))
      np.random.seed(42)
      na_indices = np.random.choice(data.index, remove_n, replace=False)
      data.iloc[na_indices] = np.nan
  
      FH = 12
      # Check that there are missing values in CV splits
      assert data[-2 * FH : -FH].isna().sum().sum() > 0
      # Check that here are missing values in test split
      assert data[-FH:].isna().sum().sum() > 0
  
      # Setup Forecasting Experiment (enable imputation) ----
      exp = TSForecastingExperiment()
      exp.setup(
          data=data,
          target=target,
          fh=FH,
          session_id=42,
          numeric_imputation_target="drift",
          numeric_imputation_exogenous="drift",
      )
  
      ##################################
      # 1: With Cross-Validation ####
      ##################################
  
      # Create a model ----
      model = exp.create_model("lr_cds_dt", cross_validation=True)
      cv_results = exp.pull()
      assert cv_results.drop(columns="cutoff").isna().sum().sum() == 0
      _ = exp.predict_model(model)
      test_results = exp.pull()
      assert test_results.isna().sum().sum() == 0
  
      #####################################
      # 2: Without Cross-Validation ####
      #####################################
  
      model = exp.create_model("lr_cds_dt", cross_validation=False)
      test_results = exp.pull()
      assert test_results.isna().sum().sum() == 0
      _ = exp.predict_model(model)
      test_results = exp.pull()
      assert test_results.isna().sum().sum() == 0
  
file_path: pycaret/tests/test_time_series_metrics.py
imports: import numpy
  import pandas
  import pytest
  from pycaret.containers.metrics.time_series import coverage
  from pycaret.datasets import get_data
  from pycaret.time_series import TSForecastingExperiment
label_desc: Use image node_id 3 for calling a global function with example usage: test_metrics_with_missing_values_exo() without return types