code: def reparam_theta_gradient(model_fn, batch_holder, hparams):
      """A gradient estimaor for the pose, theta, using the reparam trick."""
      sigma = hparams.bandwidth
      n_samples = hparams.n_noisy_samples
      latent_holder, latent, occ_eval = model_fn(
          batch_holder, None, None, "gen_mesh"
      )
  
      if hparams.sample_vert > 0:
          points = batch_holder["point"]
          weights = batch_holder["weight"]
          n_vert = tf.shape(points)[2]
          sample_indices = tf.random.uniform(
              [1, 1, hparams.sample_vert],
              minval=0,
              maxval=n_vert,
              dtype=tf.int32,
          )
          points = tf.gather(
              points, sample_indices, axis=2, batch_dims=2
          )
          weights = tf.gather(
              weights, sample_indices, axis=2, batch_dims=2
          )
          batch_holder["point"] = points
          batch_holder["weight"] = weights
      dist = tfd.Normal(loc=0.0, scale=sigma)
      n_pts = (
          hparams.sample_vert
          if hparams.sample_vert > 0
          else hparams.n_vert
      )
      noises = dist.sample(
          (1, hparams.n_parts, n_pts, n_samples, hparams.n_dims)
      )
      unused_var0, unused_var1, occ = model_fn(
          batch_holder, noises, None, "gen_mesh"
      )
      occ = tf.reshape(occ, [1, hparams.n_parts + 1, -1, n_samples, 1])
  
      occ = tf.reduce_mean(occ[:, hparams.n_parts :], axis=3)
      return (
          latent_holder,
          latent,
          occ_eval,
          tf.reduce_mean(tf.square(occ - hparams.level_set)),
      )
  
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 11 for calling a global function with example usage: reparam_theta_gradient(model_fn, batch_holder, hparams) and returns: latent_holder,  latent,  occ_eval,  tf