code: def mock_text_generation():
      with patch(
          "huggingface_hub.InferenceClient.text_generation",
          autospec=True,
      ) as mock_text_generation:
          mock_response = Mock()
          mock_response.generated_text = "I'm fine, thanks."
          details = Mock()
          details.finish_reason = MagicMock(field1="value")
          details.tokens = [1, 2, 3]
          mock_response.details = details
          mock_text_generation.return_value = mock_response
          yield mock_text_generation
  
imports: from unittest.mock import patch, MagicMock, Mock
  import pytest
  from huggingface_hub.inference._text_generation import TextGenerationStreamResponse, Token, StreamDetails, FinishReason
  from huggingface_hub.utils import RepositoryNotFoundError
  from haystack.components.generators.chat import HuggingFaceTGIChatGenerator
  from haystack.dataclasses import StreamingChunk, ChatMessage
label_desc: Use image node_id 2 for calling a global function with example usage: mock_text_generation() without return types