code: def _add_attend_to_encoder_cache(
      cache,
      attention_name,
      hparams,
      num_layers,
      key_channels,
      value_channels,
      vars_3d_num_heads,
      scope_prefix,
      encoder_output,
  ):
      """Add attend-to-encoder layers to cache."""
      for layer in range(num_layers):
          layer_name = "layer_%d" % layer
          with tf.variable_scope(
              "%sdecoder/%s/%s/multihead_attention"
              % (scope_prefix, layer_name, attention_name)
          ):
              k_encdec = common_attention.compute_attention_component(
                  encoder_output,
                  key_channels,
                  name="k",
                  vars_3d_num_heads=vars_3d_num_heads,
              )
              k_encdec = common_attention.split_heads(
                  k_encdec, hparams.num_heads
              )
              v_encdec = common_attention.compute_attention_component(
                  encoder_output,
                  value_channels,
                  name="v",
                  vars_3d_num_heads=vars_3d_num_heads,
              )
              v_encdec = common_attention.split_heads(
                  v_encdec, hparams.num_heads
              )
          cache[layer_name][attention_name] = {
              "k_encdec": k_encdec,
              "v_encdec": v_encdec,
          }
      return cache
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.models import transformer
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.python.ops import inplace_ops
label_desc: Use image node_id 4 for calling a global function with example usage: _add_attend_to_encoder_cache(cache, attention_name, hparams, num_layers, key_channels, value_channels, vars_3d_num_heads, scope_prefix, encoder_output) and returns: cache