class_docstr: Model fitted by LogisticRegression.
  
  .. versionadded:: 3.5.0
class_docstr_tok: ["Model","fitted","by","LogisticRegression",".","..","versionadded",":",":","3.5.0"]
code: def _get_transform_fn(self) -> Callable[["pd.Series"], Any]:
      model_state_dict = self.torch_model.state_dict()
      num_features = self.num_features
      num_classes = self.num_classes
      fit_intercept = self.getFitIntercept()
  
      def transform_fn(input_series: Any) -> Any:
          torch_model = torch_nn.Linear(
              num_features,  # type: ignore[arg-type]
              num_classes,  # type: ignore[arg-type]
              bias=fit_intercept,
              dtype=torch.float32,
          )
          # TODO: Use spark broadast for `model_state_dict`,
          #  it can improve performance when model is large.
          torch_model.load_state_dict(model_state_dict)
  
          input_array = np.stack(input_series.values)
  
          with torch.inference_mode():
              result = torch_model(
                  torch.tensor(input_array, dtype=torch.float32)
              )
              predictions = torch.argmax(result, dim=1).numpy()
  
          if self.getProbabilityCol():
              probabilities = torch.softmax(result, dim=1).numpy()
  
              return pd.DataFrame(
                  {
                      self.getPredictionCol(): list(predictions),
                      self.getProbabilityCol(): list(probabilities),
                  },
                  index=input_series.index.copy(),
              )
          else:
              return pd.Series(
                  data=list(predictions),
                  index=input_series.index.copy(),
              )
  
      return transform_fn
  
imports: from typing import Any, Dict, Union, List, Tuple, Callable, Optional
  import math
  import torch
  import torch.nn
  import numpy
  import pandas
  from pyspark import keyword_only
  from pyspark.ml.connect.base import _PredictorParams
  from pyspark.ml.param.shared import HasProbabilityCol
  from pyspark.sql import DataFrame
  from pyspark.ml.common import inherit_doc
  from pyspark.ml.torch.distributor import TorchDistributor
  from pyspark.ml.param.shared import HasMaxIter, HasFitIntercept, HasTol, HasWeightCol, HasSeed, HasNumTrainWorkers, HasBatchSize, HasLearningRate, HasMomentum
  from pyspark.ml.connect.base import Predictor, PredictionModel
  from pyspark.ml.connect.io_utils import ParamsReadWrite, CoreModelReadWrite
  from pyspark.sql import functions
label_desc: Use image node_id 6 for calling the LogisticRegressionModel obj's underlying member method code with example usage: obj._get_transform_fn() and returns: transform_fn, pd, pd