code: def gram_schimidt_process(embeds, num_elem, use_scale):
      """Orthogonalize embeddings."""
      num_embed = embeds.shape[0]
      assert embeds.shape[1] == num_elem
      assert embeds.shape[2] == (num_elem + int(use_scale))
      if use_scale:
          scales = embeds[:, :, -1]
          embeds = embeds[:, :, :num_elem]
  
      u = [embeds[:, 0]]
      uu = [0] * num_elem
      uu[0] = (u[0] * u[0]).sum(axis=-1)
      u_d = embeds[:, 1:]
      ushape = (num_embed, 1, -1)
      for i in range(1, num_elem):
          tmp_a = (embeds[:, i:] * u[i - 1].reshape(ushape)).sum(
              axis=-1
          )
          tmp_b = uu[i - 1].reshape((num_embed, -1))
          tmp_u = (tmp_a / tmp_b).reshape((num_embed, -1, 1))
          u_d = u_d - u[-1].reshape(ushape) * tmp_u
          u_i = u_d[:, 0]
          if u_d.shape[1] > 1:
              u_d = u_d[:, 1:]
          uu[i] = (u_i * u_i).sum(axis=-1)
          u.append(u_i)
  
      u = np.stack(u, axis=1)
      u_norm = np.linalg.norm(u, axis=-1, keepdims=True)
      u = u / u_norm
      if use_scale:
          u = np.concatenate(
              [u, scales.reshape((num_embed, -1, 1))], axis=-1
          )
      return u
  
imports: import os
  import csv
  import math
  import json
  import time
  import random
  import logging
  import functools
  import traceback
  from collections import defaultdict
  from _thread import start_new_thread
  from multiprocessing import Queue, Process
  import numpy
  from tqdm import tqdm
  import paddle
  import paddle.distributed
label_desc: Use image node_id 10 for calling a global function with example usage: gram_schimidt_process(embeds, num_elem, use_scale) and returns: u