code: def test_custom_repr_graph(self):
      import tensorflow as tf
      import tensorrec
  
      # Define a custom representation function graph
      class TanhRepresentationGraph(
          tensorrec.representation_graphs.AbstractRepresentationGraph
      ):
          def connect_representation_graph(
              self,
              tf_features,
              n_components,
              n_features,
              node_name_ending,
          ):
              """
              This representation function embeds the user/item features by passing them through a single tanh layer.
              :param tf_features: tf.SparseTensor
              The user/item features as a SparseTensor of dimensions [n_users/items, n_features]
              :param n_components: int
              The dimensionality of the resulting representation.
              :param n_features: int
              The number of features in tf_features
              :param node_name_ending: String
              Either 'user' or 'item'
              :return:
              A tuple of (tf.Tensor, list) where the first value is the resulting representation in n_components
              dimensions and the second value is a list containing all tf.Variables which should be subject to
              regularization.
              """
              tf_tanh_weights = tf.Variable(
                  tf.random_normal(
                      [n_features, n_components], stddev=0.5
                  ),
                  name="tanh_weights_%s" % node_name_ending,
              )
  
              tf_repr = tf.nn.tanh(
                  tf.sparse_tensor_dense_matmul(
                      tf_features, tf_tanh_weights
                  )
              )
  
              # Return repr layer and variables
              return tf_repr, [tf_tanh_weights]
  
      # Build a model with the custom representation function
      model = tensorrec.TensorRec(
          user_repr_graph=TanhRepresentationGraph(),
          item_repr_graph=TanhRepresentationGraph(),
      )
  
      # Generate some dummy data
      (
          interactions,
          user_features,
          item_features,
      ) = tensorrec.util.generate_dummy_data(
          num_users=100, num_items=150, interaction_density=0.05
      )
  
      # Fit the model for 5 epochs
      model.fit(
          interactions,
          user_features,
          item_features,
          epochs=5,
          verbose=True,
      )
  
      self.assertIsNotNone(model)
  
imports: from unittest import TestCase
label_desc: Use image node_id 2 for calling the ReadmeTestCase obj's underlying member method code with example usage: obj.test_custom_repr_graph() and returns: tf_repr,  list