code: def run_mistral_chatbot(
      checkpoint_dir: Optional[Path] = None,
  ) -> None:
      model_card = asset_store.retrieve_card("mistral_7b_instruct")
  
      if checkpoint_dir is not None:
          model_card.field("checkpoint").set(
              checkpoint_dir / "consolidated.00.pth"
          )
          model_card.field("tokenizer").set(
              checkpoint_dir / "tokenizer.model"
          )
  
      config = load_mistral_config(model_card)
  
      model = load_mistral_model(
          model_card, dtype=torch.float16, device=torch.device("cuda:0")
      )
  
      tokenizer = load_mistral_tokenizer(model_card)
  
      sampler = TopPSampler(p=0.8)
  
      generator = SamplingSequenceGenerator(
          model,
          sampler,
          temperature=0.6,
          max_gen_len=1024,
          max_seq_len=config.max_seq_len,
      )
  
      chatbot = MistralChatbot(generator, tokenizer)
  
      run_chatbot(chatbot)
  
file_path: fairseq2/recipes/mistral/chatbot.py
imports: from argparse import ArgumentParser
  from pathlib import Path
  from typing import Optional
  import torch
  from fairseq2.assets import asset_store
  from fairseq2.generation import Chatbot, ChatMessage, SamplingSequenceGenerator, TopPSampler
  from fairseq2.generation.utils import StdOutPrintHook
  from fairseq2.models.mistral import MistralChatbot, load_mistral_config, load_mistral_model, load_mistral_tokenizer
label_desc: Use image node_id 1 for calling a global function with example usage: run_mistral_chatbot(checkpoint_dir) without return types