class_docstr: Base test class for TensorFlow Lite 2.x model tests.
class_docstr_tok: ["Base","test","class","for","TensorFlow","Lite","2.x","model","tests","."]
code: def _createReadAssignModel(self, number_of_states=2):
      dtype = float
  
      class ReadAssign(tf.keras.layers.Layer):
          """ReadAssign model for the variable quantization test."""
  
          def __init__(self, number_of_states=2, **kwargs):
              super().__init__(**kwargs)
              self.number_of_states = number_of_states
  
          def build(self, input_shape):
              super().build(input_shape)
  
              state_shape = (1, 2, 3)
              self.states = [None] * self.number_of_states
              for i in range(self.number_of_states):
                  self.states[i] = self.add_weight(
                      name=f"states{i}",
                      shape=state_shape,
                      trainable=False,
                      initializer=tf.zeros_initializer,
                      dtype=dtype,
                  )
  
          def call(self, inputs):
              for state in self.states:
                  memory = tf.keras.backend.concatenate(
                      [state, inputs], 1
                  )
                  new_state = memory[:, : state.shape[1], :]
                  state.assign(new_state)
  
              return inputs
  
      def calibration_gen():
          for _ in range(5):
              yield [
                  np.random.uniform(-1, 1, size=(1, 2, 3)).astype(
                      np.float32
                  )
              ]
  
      inputs = tf.keras.layers.Input(
          shape=(2, 3), batch_size=1, dtype=dtype
      )
      outputs = ReadAssign(number_of_states)(inputs)
      model = tf.keras.Model(inputs, outputs)
      return model, calibration_gen
  
imports: import os
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow.lite.python.interpreter import Interpreter
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.trackable import autotrackable
label_desc: Use image node_id 11 for calling the ModelTest obj's underlying member method code with example usage: obj._createReadAssignModel(number_of_states) and returns: model,  calibration_gen, inputs