code: def compute_glue_loss(
      connect,
      end_pts,
      inv_transforms,
      inv_first_frame_trans,
      joints,
      hparams,
  ):
      """Compute the prior term as a glue loss."""
      n_dims = hparams.n_dims
  
      # Invert the transformation
      r_inv = inv_transforms[..., :n_dims, :n_dims]
      t_inv = inv_transforms[..., :n_dims, -1:]
      r = tf.transpose(r_inv, [0, 2, 1])
      t = -tf.matmul(r, t_inv)
      transforms = tf.concat(
          [tf.concat([r, t], axis=-1), inv_transforms[..., -1:, :]],
          axis=-2,
      )
      transforms = tf.matmul(transforms, inv_first_frame_trans)
  
      # Compute transformations of father joints and apply it to vectors from frame0
      father_transforms = tf.reduce_sum(
          tf.expand_dims(transforms, axis=1)
          * connect.reshape([hparams.n_parts, hparams.n_parts, 1, 1]),
          axis=0,
      )
      end_pts_homo = tf.expand_dims(
          tf.concat([end_pts, tf.ones_like(end_pts[..., :1])], axis=-1),
          axis=-1,
      )
      end_pts_transformed = tf.matmul(father_transforms, end_pts_homo)
      end_pts_transformed = tf.squeeze(end_pts_transformed, axis=-1)[
          ..., :n_dims
      ]
  
      # Compute vectors in current configuration
      pred_links = tf.reshape(joints, [hparams.n_parts, n_dims])
  
      # Compute distance between links and transformed vectors
      return tf.reduce_sum(tf.square(pred_links - end_pts_transformed))
  
imports: from os import path
  import numpy
  from skimage import measure
  import tensorflow.compat.v1
  from tensorflow_graphics.projects.cvxnet.lib.libmise import mise
  from tensorflow_graphics.projects.nasa.lib import datasets
  from tensorflow_graphics.projects.nasa.lib import models
  import tensorflow_probability
  from tqdm import trange
  import trimesh
label_desc: Use image node_id 9 for calling a global function with example usage: compute_glue_loss(connect, end_pts, inv_transforms, inv_first_frame_trans, joints, hparams) and returns: tf