code: def _save_model(
      self,
      optimizer,
      model_selection,
      model_id,
      train_acc,
      train_loss,
      valid_acc,
      valid_loss,
      stop,
      tmp_dir,
  ):
      measured_values = {
          "train_acc": train_acc,
          "train_loss": train_loss,
          "val_acc": valid_acc,
          "val_loss": valid_loss,
      }
      model_path = Path(tmp_dir).joinpath(f"model_{model_id}.pt")
      torch.save(self.model.state_dict(), model_path)
      optimizer_path = model_path.with_suffix(".pt.optimizer")
      torch.save(optimizer.state_dict(), optimizer_path)
      model_selection.add_model(
          model_id,
          model_path,
          measured_values,
          fields={ModelSelection.FIELD_NAME_EARLY_STOPPING: stop},
      )
  
imports: import logging
  import warnings
  from abc import abstractmethod
  from functools import partial
  from pathlib import Path
  from small_text.classifiers.classification import Classifier
  from small_text.integrations.pytorch.exceptions import PytorchNotFoundError
  from small_text.training.early_stopping import EarlyStopping, NoopEarlyStopping, EarlyStoppingOrCondition
  from small_text.training.metrics import Metric
  from small_text.training.model_selection import ModelSelection, NoopModelSelection
  from small_text.utils.classification import empty_result, prediction_result
label_desc: Use image node_id 1 for calling the PytorchModelSelectionMixin obj's underlying member method code with example usage: obj._save_model(optimizer, model_selection, model_id, train_acc, train_loss, valid_acc, valid_loss, stop, tmp_dir) without return types