code: def fused_featurizer(featurizer):
      featurizer_w_recompute = recompute_grads_w_kwargs(
          featurizer, use_entire_scope=True
      )
  
      @functools.wraps(featurizer)
      def internal(
          X, encoder, config, train, reuse=None, lengths=None, **kwargs
      ):
          if (
              config.num_fusion_shards is None
              or config.num_fusion_shards == 1
          ):
              return featurizer(
                  X,
                  encoder,
                  config,
                  train,
                  reuse=reuse,
                  lengths=lengths,
                  **kwargs,
              )
          orig_lengths = lengths
          out = []
          subsize = config.max_length // config.num_fusion_shards
          context = kwargs.pop("context")
          for start in range(0, config.max_length, subsize):
              xi = X[:, start : start + subsize]
              lengths = tf.maximum(lengths - tf.shape(xi)[1], 0)
              if context is not None:
                  ci = context[:, start : start + subsize]
              else:
                  ci = None
              if (
                  config.low_memory_mode
                  and config.fusion_low_memory
                  and train
              ):
                  out.append(
                      featurizer_w_recompute(
                          xi,
                          encoder,
                          config,
                          train,
                          reuse=reuse,
                          lengths=lengths,
                          max_length=subsize,
                          **kwargs,
                      )
                  )
              else:
                  out.append(
                      featurizer(
                          xi,
                          encoder,
                          config,
                          train,
                          reuse=reuse,
                          lengths=lengths,
                          max_length=subsize,
                          context=ci,
                          **kwargs,
                      )
                  )
              reuse = True
          return merge_output_state(
              out,
              X,
              orig_lengths,
              config.chunk_pos_embed,
              hidden_dim=config.n_embed,
          )
  
      return internal
  
imports: import functools
  import tensorflow
  from finetune.optimizers.recompute_grads import recompute_grads_w_kwargs
label_desc: Use image node_id 2 for calling a global function with example usage: fused_featurizer(featurizer) and returns: internal, merge_output_state, featurizer