code: def eucl_cosim_features(
      x: tf.Tensor, y: tf.Tensor, max_eucl: float = 1e2
  ) -> tf.Tensor:
      """
      Compute features extracted from the reconstructed instance using the
      relative Euclidean distance and cosine similarity between 2 tensors.
  
      Parameters
      ----------
      x
          Tensor used in feature computation.
      y
          Tensor used in feature computation.
      max_eucl
          Maximum value to clip relative Euclidean distance by.
  
      Returns
      -------
      Tensor concatenating the relative Euclidean distance and cosine similarity features.
      """
      if len(x.shape) > 2 or len(y.shape) > 2:
          x = Flatten()(x)
          y = Flatten()(y)
      rec_cos = tf.reshape(
          tf.keras.losses.cosine_similarity(y, x, -1), (-1, 1)
      )
      rec_euc = tf.reshape(
          relative_euclidean_distance(y, x, -1), (-1, 1)
      )
      # rec_euc could become very large so should be clipped
      rec_euc = tf.clip_by_value(rec_euc, 0, max_eucl)
      return tf.concat([rec_cos, rec_euc], -1)
  
imports: import numpy
  import tensorflow
  from tensorflow.keras.layers import Bidirectional, Concatenate, Dense, Flatten, Layer, LSTM
  from typing import Callable, List, Tuple
  from alibi_detect.utils.tensorflow.distance import relative_euclidean_distance
label_desc: Use image node_id 1 for calling a global function with example usage: eucl_cosim_features(x, y, max_eucl) and returns: tf