code: def mask_adaptive_embedding_lookup(
      x,
      n_token,
      d_embed,
      d_proj,
      cutoffs,
      initializer,
      proj_initializer,
      div_val=1,
      proj_same_dim=True,
      scope="adaptive_embed",
      **kwargs,
  ):
      emb_scale = d_proj**0.5
      with tf.variable_scope(scope):
          if div_val == 1:
              lookup_table = tf.get_variable(
                  "lookup_table",
                  [n_token, d_embed],
                  initializer=initializer,
              )
              y = embedding_lookup(lookup_table, x, use_tpu=False)
              if d_proj != d_embed:
                  proj_W = tf.get_variable(
                      "proj_W",
                      [d_embed, d_proj],
                      initializer=proj_initializer,
                  )
                  y = tf.einsum("ibe,ed->ibd", y, proj_W)
              else:
                  proj_W = None
              ret_params = [lookup_table, proj_W]
          else:
              tables, projs = [], []
              cutoff_ends = [0] + cutoffs + [n_token]
              x_size = tf.shape(x)
              y = tf.zeros([x_size[0], x_size[1], d_proj])
              for i in range(len(cutoff_ends) - 1):
                  with tf.variable_scope("cutoff_{}".format(i)):
                      l_idx, r_idx = cutoff_ends[i], cutoff_ends[i + 1]
                      mask = (x >= l_idx) & (x < r_idx)
                      cur_x = tf.boolean_mask(x, mask) - l_idx
                      cur_d_embed = d_embed // (div_val**i)
                      print(
                          "shape of lookup_table is {0}/{1}".format(
                              r_idx - l_idx, cur_d_embed
                          )
                      )
                      lookup_table = tf.get_variable(
                          "lookup_table",
                          [r_idx - l_idx, cur_d_embed],
                          initializer=initializer,
                      )
                      cur_y = embedding_lookup(
                          lookup_table, cur_x, use_tpu=False
                      )
                      if d_proj == cur_d_embed and not proj_same_dim:
                          proj_W = None
                      else:
                          proj_W = tf.get_variable(
                              "proj_W",
                              [cur_d_embed, d_proj],
                              initializer=proj_initializer,
                          )
                          cur_y = tf.einsum("id,de->ie", cur_y, proj_W)
                      mask_idx = tf.to_int64(tf.where(mask))
                      y += tf.scatter_nd(
                          mask_idx, cur_y, tf.to_int64(tf.shape(y))
                      )
                      tables.append(lookup_table)
                      projs.append(proj_W)
              ret_params = [tables, projs]
  
      y *= emb_scale
      return y, ret_params
  
file_path: delta/gcompiler/example/python/nlp_transformer/model.py
imports: import tensorflow
label_desc: Use image node_id 6 for calling a global function with example usage: mask_adaptive_embedding_lookup(x, n_token, d_embed, d_proj, cutoffs, initializer, proj_initializer, div_val, proj_same_dim, scope) and returns: y,  ret_params