class_docstr: Semantic retrieval model.
  
  Uses a sentence transformer model to encode the dataset and retrieve the top k most similar results to the query.
code: def _encode(
      self, row_strs: List[str], backend: "Backend"
  ) -> np.ndarray:
      # only do this step once
      if self.best_batch_size is None:
          self.best_batch_size = backend.tune_batch_size(
              create_semantic_retrieval_model_evaluator(
                  self.model, row_strs
              ),
              len(row_strs),
          )
  
      transform_fn = create_semantic_retrieval_model_fn(
          self.model, self.best_batch_size
      )
      df = backend.df_engine.from_pandas(
          pd.DataFrame({"data": row_strs})
      )
      df = backend.batch_transform(
          df, self.best_batch_size, transform_fn
      )
      df = backend.df_engine.compute(df)
      embeddings = np.stack(df["data"].values).astype(np.float32)
      return embeddings
  
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 3 for calling the SemanticRetrieval obj's underlying member method code with example usage: obj._encode(row_strs, backend) and returns: embeddings