code: def _normalize_feature_dict(
      feature: features_lib.FeatureConnector,
      expected_feature: FeatureSpecs,
  ) -> FeatureSpecs:
      """Extract the features matching the expected_feature structure."""
      if (
          type(feature) == features_lib.FeaturesDict
      ):  # pylint: disable=unidiomatic-typecheck
          inner_features = {
              k: v
              for k, v in expected_feature.items()
              if v is not False  # pylint: disable=g-bool-id-comparison
          }
          inner_features = {  # Extract the feature subset  # pylint: disable=g-complex-comprehension
              k: _extract_feature_item(  # pytype: disable=wrong-arg-types  # always-use-return-annotations
                  feature=feature,
                  expected_key=k,
                  expected_value=v,
                  fn=_normalize_feature_item,
              )
              for k, v in inner_features.items()
          }
          # Filter `False` values
          return inner_features
      elif (
          type(feature) == features_lib.Sequence
      ):  # pylint: disable=unidiomatic-typecheck
          inner_features = _normalize_feature_dict(
              feature=feature.feature,  # pytype: disable=attribute-error
              expected_feature=expected_feature,
          )
          return features_lib.Sequence(inner_features)
      else:
          raise ValueError(
              f"Unexpected structure {expected_feature!r} does not match {feature!r}"
          )
  
file_path: datasets/tensorflow_datasets/core/decode/partial_decode.py
imports: import typing
  from typing import Any, Callable, Optional, Union
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.decode import base
  from tensorflow_datasets.core.features import features_dict
  from tensorflow_datasets.core.utils import dtype_utils
label_desc: Use image node_id 2 for calling a global function with example usage: _normalize_feature_dict(feature, expected_feature) and returns: inner_features, features_lib