code: def test_trainable_setting(self):
      class NonTrainableWeightsLayer(layers.Layer):
          def build(self, _):
              self.w1 = self.add_weight(
                  shape=(),
                  initializer="ones",
                  trainable=True,
              )
              self.w2 = self.add_weight(
                  shape=(),
                  initializer="ones",
                  trainable=False,
              )
              self.seed = backend.random.SeedGenerator(123)
  
          def call(self, inputs):
              return inputs
  
      class NestedNonTrainableWeightsLayer(layers.Layer):
          def build(self, _):
              self.w1 = self.add_weight(
                  shape=(),
                  initializer="ones",
                  trainable=True,
              )
              self.w2 = self.add_weight(
                  shape=(),
                  initializer="ones",
                  trainable=False,
              )
              self.nested = NonTrainableWeightsLayer()
              self.nested.build(None)
  
          def call(self, inputs):
              return inputs
  
      layer = NestedNonTrainableWeightsLayer()
      layer.build(None)
      self.assertEqual(len(layer.trainable_weights), 2)
      self.assertEqual(len(layer.trainable_variables), 2)
      self.assertEqual(len(layer.non_trainable_weights), 2)
      self.assertEqual(len(layer.non_trainable_variables), 3)
  
      layer.trainable = False
      self.assertEqual(len(layer.trainable_weights), 0)
      self.assertEqual(len(layer.trainable_variables), 0)
      self.assertEqual(len(layer.non_trainable_weights), 4)
      self.assertEqual(len(layer.non_trainable_variables), 5)
      self.assertFalse(layer.w1.trainable)
      self.assertFalse(layer.nested.w1.trainable)
  
      layer.trainable = True
      self.assertEqual(len(layer.trainable_weights), 2)
      self.assertEqual(len(layer.trainable_variables), 2)
      self.assertEqual(len(layer.non_trainable_weights), 2)
      self.assertEqual(len(layer.non_trainable_variables), 3)
      self.assertTrue(layer.w1.trainable)
      self.assertTrue(layer.nested.w1.trainable)
  
      layer = NestedNonTrainableWeightsLayer(trainable=False)
      layer.build(None)
      self.assertEqual(len(layer.trainable_weights), 0)
      self.assertEqual(len(layer.trainable_variables), 0)
      self.assertEqual(len(layer.non_trainable_weights), 4)
      self.assertEqual(len(layer.non_trainable_variables), 5)
  
      layer.trainable = True
      self.assertEqual(len(layer.trainable_weights), 2)
      self.assertEqual(len(layer.trainable_variables), 2)
      self.assertEqual(len(layer.non_trainable_weights), 2)
      self.assertEqual(len(layer.non_trainable_variables), 3)
  
imports: import numpy
  import pytest
  from keras import backend
  from keras import layers
  from keras import metrics
  from keras import models
  from keras import ops
  from keras import testing
label_desc: Use image node_id 14 for calling the LayerTest obj's underlying member method code with example usage: obj.test_trainable_setting() and returns: inputs, inputs