code: def test_text_feature_uses_visualization_transform_if_provided(
      self,
  ) -> None:
      input_data = torch.rand(2, 2)
      transformed_data = torch.rand(1, 1)
  
      def mock_transform(data):
          return transformed_data
  
      feature = TextFeature(
          name=self.FEATURE_NAME,
          baseline_transforms=None,
          input_transforms=None,
          visualization_transform=mock_transform,
      )
  
      feature_output = feature.visualize(
          attribution=torch.rand(1, 1),
          data=input_data,
          contribution_frac=1.0,
      )
  
      # has transformed data
      self.assertEqual(feature_output.base, transformed_data)
  
      feature = TextFeature(
          name=self.FEATURE_NAME,
          baseline_transforms=None,
          input_transforms=None,
          visualization_transform=None,
      )
  
      feature_output = feature.visualize(
          attribution=torch.rand(1, 1),
          data=input_data,
          contribution_frac=1.0,
      )
  
      # has original data
      self.assertIs(feature_output.base, input_data)
  
file_path: captum/tests/insights/test_features.py
imports: from unittest.mock import patch
  import torch
  from captum.insights.attr_vis.features import _convert_figure_base64, EmptyFeature, FeatureOutput, GeneralFeature, ImageFeature, TextFeature
  from matplotlib.figure import Figure
  from tests.helpers.basic import BaseTest
label_desc: Use image node_id 2 for calling the TestTextFeature obj's underlying member method code with example usage: obj.test_text_feature_uses_visualization_transform_if_provided() and returns: transformed_data