code: def create_semantic_retrieval_model_fn(
      model: "SentenceTransformer", batch_size: int
  ) -> Callable[[pd.DataFrame], np.ndarray]:
      class _RetrievalModelFn:
          def __init__(self):
              self.model = model.to(get_torch_device())
              self.batch_size = batch_size
  
          def __call__(self, df: pd.DataFrame) -> np.ndarray:
              row_strs = df["data"].tolist()
              result = self.model.encode(
                  row_strs,
                  batch_size=self.batch_size,
                  show_progress_bar=False,
              )
              df["data"] = result.tolist()
              return df
  
      return _RetrievalModelFn
  
imports: import hashlib
  import json
  import os
  from abc import ABC, abstractmethod
  from typing import Any, Callable, Dict, List, Optional, Type, TYPE_CHECKING, Union
  import numpy
  import pandas
  from tqdm import tqdm
  from ludwig.vector_index import FAISS, get_vector_index_cls
  from ludwig.vector_index.base import VectorIndex
  from ludwig.utils.batch_size_tuner import BatchSizeEvaluator
  from ludwig.utils.torch_utils import get_torch_device
label_desc: Use image node_id 4 for calling a global function with example usage: create_semantic_retrieval_model_fn(model, batch_size) and returns: _RetrievalModelFn, df