code: def _calculate_metafeatures_encoded(
      data_feat_type,
      basename,
      x_train,
      y_train,
      stopwatch: StopWatch,
      task,
      logger_,
  ):
      with warnings.catch_warnings():
          warnings.showwarning = get_send_warnings_to_logger(logger_)
  
          EXCLUDE_META_FEATURES = (
              EXCLUDE_META_FEATURES_CLASSIFICATION
              if task in CLASSIFICATION_TASKS
              else EXCLUDE_META_FEATURES_REGRESSION
          )
  
          with stopwatch.time(
              "Calculate meta-features encoded"
          ) as task_timer:
              result = calculate_all_metafeatures_encoded_labels(
                  x_train,
                  y_train,
                  feat_type=data_feat_type,
                  dataset_name=basename,
                  dont_calculate=EXCLUDE_META_FEATURES,
                  logger=logger_,
              )
              for key in list(result.metafeature_values.keys()):
                  if (
                      result.metafeature_values[key].type_
                      != "METAFEATURE"
                  ):
                      del result.metafeature_values[key]
  
          logger_.info(
              f"{task_timer.name} took {task_timer.wall_duration:5.2f}sec"
          )
          return result
  
imports: import typing
  from typing import Dict, List, Optional, Sequence
  import copy
  import json
  import logging
  import multiprocessing
  import os
  import time
  import traceback
  import warnings
  import dask.distributed
  import pynisher
  from smac.callbacks import IncorporateRunResultCallback
  from smac.facade.smac_ac_facade import SMAC4AC
  from smac.intensification.intensification import Intensifier
  from smac.intensification.simple_intensifier import SimpleIntensifier
  from smac.optimizer.multi_objective.parego import ParEGO
  from smac.runhistory.runhistory2epm import RunHistory2EPM4LogCost
  from smac.scenario.scenario import Scenario
  from smac.tae.dask_runner import DaskParallelRunner
  from smac.tae.serial_runner import SerialRunner
  import autosklearn.metalearning
  from autosklearn.constants import BINARY_CLASSIFICATION, CLASSIFICATION_TASKS, MULTICLASS_CLASSIFICATION, MULTILABEL_CLASSIFICATION, MULTIOUTPUT_REGRESSION, REGRESSION, TASK_TYPES_TO_STRING
  from autosklearn.data.abstract_data_manager import AbstractDataManager
  from autosklearn.ensemble_building import EnsembleBuilderManager
  from autosklearn.evaluation import ExecuteTaFuncWithQueue, get_cost_of_crash
  from autosklearn.metalearning.metafeatures.metafeatures import calculate_all_metafeatures_encoded_labels, calculate_all_metafeatures_with_labels
  from autosklearn.metalearning.metalearning.meta_base import MetaBase
  from autosklearn.metalearning.mismbo import suggest_via_metalearning
  from autosklearn.metrics import Scorer
  from autosklearn.util.logging_ import get_named_client_logger
  from autosklearn.util.parallel import preload_modules
  from autosklearn.util.stopwatch import StopWatch
label_desc: Use image node_id 3 for calling a global function with example usage: _calculate_metafeatures_encoded(data_feat_type, basename, x_train, y_train, stopwatch, task, logger_) and returns: result