code: def _train_model(
      model: torch.nn.Module,
      train_data: List[Tuple[Tuple, Any]],
      eval_data: List[Tuple[Tuple, Any]],
      epochs_pruning_window: Dict = None,
      training_epochs: int = 10,
      lr: float = 1e-3,
      momentum: float = 0.9,
      loss_fn: str = "CrossEntropy",
  ):
      batch_size = train_data[0][0][0].shape[0]
      with TemporaryDirectory() as tmp_dir:
          onnx_path = _export_model_onnx(
              model, Path(tmp_dir), "model.onnx", train_data[0][0]
          )
          onnx_path = onnx_path.as_posix()
  
          recipe = RecipeBuilder(onnx_path)
          # TODO: implement custom parameters support
          manager = recipe.build_recipe(
              epochs_pruning_window=epochs_pruning_window,
              training_epochs=training_epochs,
          )
          trainer = PruningTrainer(model, batch_size)
          pruned_model = trainer.train(
              manager, train_data, eval_data, lr=lr, momentum=momentum
          )
          return pruned_model
  
imports: import json
  import logging
  import os.path
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Tuple, List, Any, Dict
  import torch
  from sparseml.onnx.optim import ModelAnalyzer, pruning_loss_sens_magnitude
  from sparseml.pytorch.optim import ScheduledModifierManager
  from sparseml.pytorch.sparsification import EpochRangeModifier, GMPruningModifier
  from sparseml.pytorch.utils import ModuleExporter
  from sparsify.blueprints.utils import default_epochs_distribution, PruningModelEvaluator, default_pruning_settings
  from sparsify.schemas import ProjectModelAnalysisSchema
  from torch.nn import CrossEntropyLoss, MSELoss
  from torch.optim import SGD
  from tqdm.auto import tqdm
label_desc: Use image node_id 5 for calling a global function with example usage: _train_model(model, train_data, eval_data, epochs_pruning_window, training_epochs, lr, momentum, loss_fn) and returns: pruned_model