src/transformers/models/xglm/modeling_tf_xglm.py/TFXGLMModel/serving_output
class TFXGLMModel:    def serving_output(self, output):
        pkv = tf.convert_to_tensor(output.past_key_values) if self.config.use_cache else None
        hs = tf.convert_to_tensor(output.hidden_states) if self.config.output_hidden_states else None
        attns = tf.convert_to_tensor(output.attentions) if self.config.output_attentions else None
        cross_attns = (
            tf.convert_to_tensor(output.cross_attentions)
            if self.config.output_attentions and self.config.add_cross_attention
            else None
        )

        return TFBaseModelOutputWithPastAndCrossAttentions(
            last_hidden_state=output.hidden_states,
            past_key_values=pkv,
            hidden_states=hs,
            attentions=attns,
            cross_attentions=cross_attns,
        )