code: def create_embed_transform_fn(
      features_to_encode: List[FeatureConfigDict],
      metadata: TrainingSetMetadataDict,
  ) -> Callable:
      class EmbedTransformFn:
          def __init__(self):
              embedder = Embedder(features_to_encode, metadata)
              self.device = get_torch_device()
              self.embedder = embedder.to(self.device)
              self.embedder.eval()
  
          def __call__(self, df: pd.DataFrame) -> pd.DataFrame:
              batch = _prepare_batch(df, features_to_encode, metadata)
              name_to_proc = {
                  i_feat.feature_name: i_feat.proc_column
                  for i_feat in self.embedder.input_features.values()
              }
              inputs = {
                  i_feat.feature_name: torch.from_numpy(
                      np.array(batch[i_feat.proc_column], copy=True)
                  ).to(self.device)
                  for i_feat in self.embedder.input_features.values()
              }
              with torch.no_grad():
                  encoder_outputs = self.embedder(inputs)
  
              encoded = {
                  name_to_proc[k]: v.detach().cpu().float().numpy()
                  for k, v in encoder_outputs.items()
              }
              output_df = from_numpy_dataset(encoded)
  
              for c in output_df.columns:
                  df[c] = output_df[c]
  
              return df
  
      return EmbedTransformFn
  
imports: from typing import Callable, Dict, List
  import numpy
  import pandas
  import torch
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import ENCODER_OUTPUT, MODEL_ECD, NAME, PROC_COLUMN, TYPE
  from ludwig.features.feature_registries import get_input_type_registry
  from ludwig.features.feature_utils import LudwigFeatureDict
  from ludwig.models.base import BaseModel
  from ludwig.schema.features.base import BaseInputFeatureConfig, FeatureCollection
  from ludwig.schema.features.utils import get_input_feature_cls
  from ludwig.types import FeatureConfigDict, TrainingSetMetadataDict
  from ludwig.utils.batch_size_tuner import BatchSizeEvaluator
  from ludwig.utils.dataframe_utils import from_numpy_dataset
  from ludwig.utils.misc_utils import get_from_registry
  from ludwig.utils.torch_utils import get_torch_device, LudwigModule
label_desc: Use image node_id 2 for calling a global function with example usage: create_embed_transform_fn(features_to_encode, metadata) and returns: EmbedTransformFn, df