code: def encode_decoder_one_scene(
      near_surface_samples,
      ckpt_dir,
      part_size,
      overlap,
      indep_pt_loss,
      xmin=np.zeros(3),
      xmax=np.ones(3),
      res_per_part=16,
      npts=4096,
      init_std=1e-4,
      learning_rate=1e-3,
      steps=10000,
      nows=False,
      verbose=False,
  ):
      """Wrapper function for encoding and decoding one scene.
  
      Args:
        near_surface_samples: [npts*sample_factor, 4], where last dimension is
        distance to surface point.
        ckpt_dir: str, path to checkpoint directory to use.
        part_size: float, size of each part to use when autodecoding.
        overlap: bool, whether to use overlapping encoding.
        indep_pt_loss: bool, whether to use independent point loss in optimization.
        xmin: np.array of len 3, lower coordinates of the domain bounds.
        xmax: np.array of len 3, upper coordinates of the domain bounds.
        res_per_part: int, resolution of output evaluation per part.
        npts: int, number of points to use per step when doing gradient descent.
        init_std: float, std to use when initializing seed.
        learning_rate: float, learning rate for doing gradient descent.
        steps: int, number of optimization steps to take.
        nows: bool, no warmstarting from checkpoint. use random codebook.
        verbose: bool, verbose mode.
      Returns:
        v: float32 np.array, vertices of reconstructed mesh.
        f: int32 np.array, faces of reconstructed mesh.
        feat_grid: float32 np.array, feature grid.
        mask: bool np.array, mask of occupied cells.
      """
      ckpt = tf.train.latest_checkpoint(ckpt_dir)
      np.random.shuffle(near_surface_samples)
      param_file = os.path.join(ckpt_dir, "params.txt")
      params = evaluator.parse_param_file(param_file)
  
      _, occ_idx, grid_shape = pt.np_get_occupied_idx(
          near_surface_samples[:100000, :3],
          xmin=xmin - 0.5 * part_size,
          xmax=xmax + 0.5 * part_size,
          crop_size=part_size,
          ntarget=1,
          overlap=overlap,
          normalize_crops=False,
          return_shape=True,
      )
      npts = min(npts, near_surface_samples.shape[0])
      if verbose:
          print("LIG shape: {}".format(grid_shape))
      if verbose:
          print("Optimizing latent codes in LIG...")
      goptim = LIGOptimizer(
          ckpt,
          origin=xmin,
          grid_shape=grid_shape,
          part_size=part_size,
          occ_idx=occ_idx,
          indep_pt_loss=indep_pt_loss,
          overlap=overlap,
          alpha_lat=params["alpha_lat"],
          npts=npts,
          init_std=init_std,
          learning_rate=learning_rate,
          var_prefix="",
          nows=nows,
      )
  
      goptim.optimize_feat_grid(
          near_surface_samples[:, :3],
          near_surface_samples[:, 3:],
          steps=steps,
      )
  
      mask = occupancy_sparse_to_dense(occ_idx, grid_shape)
  
      # evaluate mesh for the current crop
      if verbose:
          print("Extracting mesh from LIG...")
      svg = evaluator.SparseLIGEvaluator(
          ckpt,
          num_filters=params["refiner_nf"],
          codelen=params["codelen"],
          origin=xmin,
          grid_shape=grid_shape,
          part_size=part_size,
          overlap=overlap,
          scope="",
      )
      feat_grid = goptim.feature_grid[0]
      out_grid = svg.evaluate_feature_grid(
          feat_grid, mask=mask, res_per_part=res_per_part
      )
  
      v, f, _, _ = measure.marching_cubes_lewiner(out_grid, 0)
      v *= (
          part_size
          / float(res_per_part)
          * float(out_grid.shape[0])
          / (float(out_grid.shape[0]) - 1)
      )
      v += xmin
  
      return v, f, feat_grid, mask
  
imports: import os
  import numpy
  from skimage import measure
  import tensorflow.compat.v1
  from tensorflow_graphics.projects.local_implicit_grid.core import evaluator
  from tensorflow_graphics.projects.local_implicit_grid.core import local_implicit_grid_layer
  from tensorflow_graphics.projects.local_implicit_grid.core import point_utils
label_desc: Use image node_id 5 for calling a global function with example usage: encode_decoder_one_scene(near_surface_samples, ckpt_dir, part_size, overlap, indep_pt_loss, xmin, xmax, res_per_part, npts, init_std, learning_rate, steps, nows, verbose) and returns: v,  f,  feat_grid,  mask