docstr: Returns number of non trainable parameters.
  
  Returns the number of parameters that are non trainable. If no trainable parameter exists we raise
  a `ValueError`.
docstr_tok: ["Returns","number","of","non","trainable","parameters",".","Returns","the","number","of","parameters","that","are","non","trainable",".","If","no","trainable","parameter","exists","we","raise","a","`","ValueError","`","."]
code: def _count_non_trainable(model: nn.Module) -> int:
      """Returns number of non trainable parameters.
  
      Returns the number of parameters that are non trainable. If no trainable parameter exists we raise
      a `ValueError`.
      """
  
      num_non_trainable_params = len(
          [
              param
              for param in model.parameters()
              if not param.requires_grad
          ]
      )
  
      if num_non_trainable_params == len(list(model.parameters())):
          raise ValueError(
              "The model has no trainable parameters. This method requires at least "
              "one trainable parameter to compute the gradients for. "
              "Try setting ``.requires_grad_(True)`` on the model or one of its parameters."
          )
  
      return num_non_trainable_params
  
file_path: alibi/alibi/explainers/similarity/backends/pytorch/base.py
imports: from typing import Any, Callable, List, Optional, Union
  import numpy
  import torch
  import torch.nn
label_desc: Use image node_id 7 for calling the _PytorchBackend obj's underlying member method code with example usage: obj._count_non_trainable(model) and returns: num_non_trainable_params