docstr: This function is responsible of sanitizing ``parameters_to_prune`` and ``parameter_names``. If
  ``parameters_to_prune is None``, it will be generated with all parameters of the model.
  
  Raises:
      MisconfigurationException:
          If ``parameters_to_prune`` doesn't exist in the model, or
          if ``parameters_to_prune`` is neither a list nor a tuple.
docstr_tok: ["This","function","is","responsible","of","sanitizing","``","parameters_to_prune","``","and","``","parameter_names","``",".","If","``","parameters_to_prune","is","None","``",",","it","will","be","generated","with","all","parameters","of","the","model",".","Raises",":","MisconfigurationException",":","If","``","parameters_to_prune","``","does","n't","exist","in","the","model",",","or","if","``","parameters_to_prune","``","is","neither","a","list","nor","a","tuple","."]
code: def sanitize_parameters_to_prune(
      pl_module: LightningModule,
      parameters_to_prune: _PARAM_LIST = (),
      parameter_names: Sequence[str] = (),
  ) -> _PARAM_LIST:
      """This function is responsible of sanitizing ``parameters_to_prune`` and ``parameter_names``. If
      ``parameters_to_prune is None``, it will be generated with all parameters of the model.
  
      Raises:
          MisconfigurationException:
              If ``parameters_to_prune`` doesn't exist in the model, or
              if ``parameters_to_prune`` is neither a list nor a tuple.
  
      """
      parameters = parameter_names or ModelPruning.PARAMETER_NAMES
  
      current_modules = [
          m
          for m in pl_module.modules()
          if not isinstance(m, _MODULE_CONTAINERS)
      ]
  
      if not parameters_to_prune:
          parameters_to_prune = [
              (m, p)
              for p in parameters
              for m in current_modules
              if getattr(m, p, None) is not None
          ]
      elif (
          isinstance(parameters_to_prune, (list, tuple))
          and len(parameters_to_prune) > 0
          and all(len(p) == 2 for p in parameters_to_prune)
          and all(
              isinstance(a, nn.Module) and isinstance(b, str)
              for a, b in parameters_to_prune
          )
      ):
          missing_modules, missing_parameters = [], []
          for module, name in parameters_to_prune:
              if module not in current_modules:
                  missing_modules.append(module)
                  continue
              if not hasattr(module, name):
                  missing_parameters.append(name)
  
          if missing_modules or missing_parameters:
              raise MisconfigurationException(
                  "Some provided `parameters_to_prune` don't exist in the model."
                  f" Found missing modules: {missing_modules} and missing parameters: {missing_parameters}"
              )
      else:
          raise MisconfigurationException(
              "The provided `parameters_to_prune` should either be list of tuple"
              " with 2 elements: (nn.Module, parameter_name_to_prune) or None"
          )
  
      return parameters_to_prune
  
imports: import inspect
  import logging
  from copy import deepcopy
  from functools import partial
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
  import torch.nn.utils.prune
  from lightning_utilities.core.apply_func import apply_to_collection
  from torch import Tensor, nn
  from typing_extensions import TypedDict, override
  import lightning.pytorch
  from lightning.pytorch.callbacks.callback import Callback
  from lightning.pytorch.core.module import LightningModule
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.rank_zero import rank_zero_debug, rank_zero_only
label_desc: Use image node_id 21 for calling the ModelPruning obj's underlying member method code with example usage: obj.sanitize_parameters_to_prune(pl_module, parameters_to_prune, parameter_names) and returns: parameters_to_prune