code: def uv_stiching(
      img_uv_list,
      angle_uv_list,
      smoothing_sigma=10,
      seamless_clone=False,
  ):
      max_ind = np.argmax(np.array(angle_uv_list).mean(axis=1), axis=0)
      mask_out_all = (
          np.max(np.array(angle_uv_list).mean(axis=1), axis=0) == -1
      )
      max_ind[mask_out_all] = len(img_uv_list) - 1
      all_uvs = np.clip(np.array(img_uv_list), 0, 1)
  
      max_ind_one_hot = np.zeros((max_ind.size, len(img_uv_list)))
      max_ind_one_hot[np.arange(max_ind.size), max_ind.flatten()] = 1
      max_ind_one_hot = max_ind_one_hot.reshape(max_ind.shape + (-1,))
  
      if smoothing_sigma > 0:
          max_ind_one_hot_g = gaussian(
              max_ind_one_hot,
              sigma=smoothing_sigma,
              multichannel=True,
              mode="reflect",
          )
      else:
          max_ind_one_hot_g = max_ind_one_hot
  
      max_ind_one_hot = np.tile(max_ind_one_hot, [3, 1, 1, 1])
      max_ind_one_hot = np.transpose(max_ind_one_hot, [3, 0, 1, 2])
  
      max_ind_one_hot_g = np.tile(max_ind_one_hot_g, [3, 1, 1, 1])
      max_ind_one_hot_g = np.transpose(max_ind_one_hot_g, [3, 0, 1, 2])
  
      if seamless_clone:
          all_uvs_uint8 = (
              np.transpose(all_uvs, [0, 2, 3, 1]) * 255
          ).astype(np.uint8)
          max_ind_one_uint8 = (
              np.transpose(1 - max_ind_one_hot, [0, 2, 3, 1]) * 255
          ).astype(np.uint8)
          max_ind_one_uint8_g = (
              np.transpose(1 - max_ind_one_hot_g, [0, 2, 3, 1]) * 255
          ).astype(np.uint8)
  
          dst = (
              Image(
                  np.sum(all_uvs * max_ind_one_hot_g, axis=0)
              ).pixels_with_channels_at_back()
              * 255
          ).astype(np.uint8)
          for i, (src, mask, mask_g) in enumerate(
              zip(
                  all_uvs_uint8[1:],
                  max_ind_one_uint8[1:],
                  max_ind_one_uint8_g[1:],
              )
          ):
              mask_inv = 255 - mask.copy()
              mask_inv[:, 0:5] = 255
              mask_inv[:, -6:-1] = 255
              mask_inv[0:5, :] = 255
              mask_inv[-6:-1, :] = 255
              mask_inv_dilated = (
                  binary_dilation(
                      mask_inv.astype(np.bool)[:, :, 0], disk(50)
                  ).astype(np.uint8)
                  * 255
              )
              mask_inv_dilated = np.transpose(
                  np.tile(mask_inv_dilated, [3, 1, 1]), [1, 2, 0]
              )
  
              mask_inv_dilated_g = gaussian(
                  mask_inv_dilated / 255,
                  sigma=100,
                  multichannel=True,
                  mode="reflect",
              )
              mixed = (
                  src * mask_inv_dilated_g
                  + dst * (1 - mask_inv_dilated_g)
              ).astype(np.uint8)
  
              im_clone = cv.seamlessClone(
                  dst, mixed, mask_inv, (512, 512), cv.NORMAL_CLONE
              )
              dst = (
                  im_clone * (1 - mask_g / 255) + dst * (mask_g / 255)
              ).astype(np.uint8)
          final_uv = Image(
              np.transpose(dst.astype(np.float) / 255, [2, 0, 1])
          )
      else:
          final_uv = Image(np.sum(all_uvs * max_ind_one_hot_g, axis=0))
  
      final_uv.pixels = np.clip(final_uv.pixels, 0.0, 1.0)
      return final_uv, max_ind_one_hot
  
imports: import PIL.Image
  from skimage.morphology import binary_dilation, disk
  from skimage.filters import gaussian
  from scipy.interpolate import NearestNDInterpolator
  import cv2
  from utils.shading import lambertian_shading
  from menpo3d.rasterize import rasterize_mesh
  from menpo.shape import TriMesh, TexturedTriMesh, ColouredTriMesh
  from menpo.image import Image
  from utils.image_rasterization import *
  import menpo.io
  import os
  from keras.utils import get_file
  import bz2
label_desc: Use image node_id 6 for calling a global function with example usage: uv_stiching(img_uv_list, angle_uv_list, smoothing_sigma, seamless_clone) and returns: final_uv,  max_ind_one_hot