code: def test_non_trainable_layer_warnings_pt():
      """Test non-trainable layer warnings `pytorch`.
  
      Test that warnings are raised when user passes non-trainbable layers to to `GradientSimilarity` method for
      `pytorch` models.
      """
  
      class Model(nn.Module):
          def __init__(self, input_shape, output_shape):
              super(Model, self).__init__()
              self.linear_stack = nn.Sequential(
                  nn.Flatten(start_dim=1),
                  nn.Linear(input_shape, output_shape),
                  nn.Linear(output_shape, output_shape),
                  nn.BatchNorm1d(output_shape),
                  nn.Sequential(
                      nn.Linear(output_shape, output_shape),
                      nn.Linear(output_shape, output_shape),
                  ),
                  nn.Softmax(),
              )
  
          def forward(self, x):
              x = x.type(torch.FloatTensor)
              return self.linear_stack(x)
  
      model = Model(10, 20)
      model.linear_stack[2].weight.requires_grad = False
      model.linear_stack[4][1].weight.requires_grad = False
      num_params_non_trainable = len(
          [
              param
              for param in model.parameters()
              if not param.requires_grad
          ]
      )
  
      loss_fn = nn.CrossEntropyLoss()
  
      with pytest.warns(Warning) as record:
          GradientSimilarity(
              model,
              task="classification",
              loss_fn=loss_fn,
              backend="pytorch",
          )
  
      assert (
          f"Found {num_params_non_trainable} non-trainable parameters in the model. These parameters "
          "don't have gradients and will not be included in the computation of gradient similarity."
          " This might be because your model has layers that track statistics using non-trainable "
          "parameters such as batch normalization layers. In this case, you don't need to worry. "
          "Otherwise it's because you have set some parameters to be non-trainable and alibi is "
          "letting you know."
      ) == str(record[0].message)
  
imports: import pytest
  import numpy
  import torch.nn
  import torch
  import tensorflow
  from tensorflow import keras
  from alibi.explainers.similarity.grad import GradientSimilarity
label_desc: Use image node_id 18 for calling a global function with example usage: test_non_trainable_layer_warnings_pt() and returns: self