code: def chat(self, text, image=None, history=None, **kwargs):
      text_embeds = self.encode_text(text)
      img_embeds = self.encode_img(image)
      prompt_embeds = self.wrap_prompt(
          text_embeds, img_embeds, history=history
      )
      out_embeds = self.internlm_model.generate(
          inputs_embeds=prompt_embeds, **self.get_gen_args(**kwargs)
      )
      out_text = self.decode_text(out_embeds)
  
      # trunc at eoh and eoa
      clean_out_text_token_ids = self.tokenizer(
          out_text, return_tensors="pt"
      ).input_ids.to(self.device)
      clean_out_text_embeds = self.internlm_model.model.embed_tokens(
          clean_out_text_token_ids
      )
      clean_prompt_embeds = self.wrap_prompt(
          text_embeds, img_embeds, add_special=False
      )
      cur_history = torch.cat(
          [clean_prompt_embeds, clean_out_text_embeds], dim=1
      )
      if history is None:
          history = []
      history.append(cur_history)
      return out_text, history
  
imports: import copy
  import os
  import sys
  import contextlib
  import torch.utils.checkpoint
  from torch.nn import LayerNorm
  from torchvision import transforms
  from torchvision.transforms.functional import InterpolationMode
  from PIL import Image
  from .modeling_perceive_sampler import BertConfig, BertLMHeadModel
  from .modeling_vit import *
  from .modeling_InternLM import *
  from .modeling_utils import *
  from transformers.utils import logging
label_desc: Use image node_id 12 for calling the InternLMXComposerForCausalLM obj's underlying member method code with example usage: obj.chat(text, image, history) and returns: out_text,  history