code: def slicenet_internal(
      inputs, targets, target_space, hparams, run_decoder=True
  ):
      """The slicenet model, main step used for training."""
      with tf.variable_scope("slicenet"):
          # Project to hidden size if necessary
          if inputs.get_shape().as_list()[-1] != hparams.hidden_size:
              inputs = common_layers.conv_block(
                  inputs,
                  hparams.hidden_size,
                  [((1, 1), (3, 3))],
                  first_relu=False,
                  padding="SAME",
                  force2d=True,
              )
  
          # Flatten inputs and encode.
          inputs = tf.expand_dims(
              common_layers.flatten4d3d(inputs), axis=2
          )
          inputs_mask = 1.0 - embedding_to_padding(inputs)
          inputs = common_layers.add_timing_signal(
              inputs
          )  # Add position info.
          target_space_emb = embed_target_space(
              target_space, hparams.hidden_size
          )
          extra_layers = int(hparams.num_hidden_layers * 1.5)
          inputs_encoded = multi_conv_res(
              inputs,
              "SAME",
              "encoder",
              extra_layers,
              hparams,
              mask=inputs_mask,
          )
          if not run_decoder:
              return inputs_encoded
          # Do the middle part.
          decoder_start, similarity_loss = slicenet_middle(
              inputs_encoded,
              targets,
              target_space_emb,
              inputs_mask,
              hparams,
          )
          # Decode.
          decoder_final = multi_conv_res(
              decoder_start,
              "LEFT",
              "decoder",
              hparams.num_hidden_layers,
              hparams,
              mask=inputs_mask,
              source=inputs_encoded,
          )
          return decoder_final, tf.reduce_mean(similarity_loss)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from six.moves import range
  from six.moves import zip
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_hparams
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import modalities
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
label_desc: Use image node_id 8 for calling a global function with example usage: slicenet_internal(inputs, targets, target_space, hparams, run_decoder) and returns: decoder_final,  tf, inputs_encoded