def track(self, resource):
        """Track the variables (of a layer or model) and other assets.

        By default, all variables used by an endpoint function are automatically
        tracked when you call `add_endpoint()`. However, non-variables assets
        such as lookup tables need to be tracked manually. Note that lookup
        tables used by built-in Keras layers (`TextVectorization`,
        `IntegerLookup`, `StringLookup`) are automatically tracked by
        `add_endpoint()`.

        Args:
            resource: A layer, model or a TensorFlow trackable resource.
        """
        if isinstance(resource, layers.Layer) and not resource.built:
            raise ValueError(
                "The layer provided has not yet been built. "
                "It must be built before export."
            )

        # Note: with the TensorFlow backend, Layers and Models fall into both
        # the Layer case and the Trackable case. The Trackable case is needed
        # for preprocessing layers in order to track lookup tables.
        if isinstance(resource, tf.__internal__.tracking.Trackable):
            if not hasattr(self, "_tracked"):
                self._tracked = []
            self._tracked.append(resource)

        if isinstance(resource, layers.Layer):
            self._track_layer(resource)
        elif not isinstance(resource, tf.__internal__.tracking.Trackable):
            raise ValueError(
                "Invalid resource type. Expected a Keras `Layer` or `Model` "
                "or a TensorFlow `Trackable` object. "
                f"Received object {resource} of type '{type(resource)}'. "
            )
Track the variables (of a layer or model) and other assets.

        By default, all variables used by an endpoint function are automatically
        tracked when you call `add_endpoint()`. However, non-variables assets
        such as lookup tables need to be tracked manually. Note that lookup
        tables used by built-in Keras layers (`TextVectorization`,
        `IntegerLookup`, `StringLookup`) are automatically tracked by
        `add_endpoint()`.

        Args:
            resource: A layer, model or a TensorFlow trackable resource.
        
keras/src/export/saved_model.py