code: def test_visualize_feature_importance(
      top_k,
      node_mask_type,
      tmp_path,
      hetero_data,
  ):
      explanation = create_random_explanation(
          hetero_data,
          node_mask_type=node_mask_type,
      )
  
      path = osp.join(tmp_path, "feature_importance.png")
  
      if node_mask_type is None:
          with pytest.raises(
              KeyError, match="Tried to collect 'node_mask'"
          ):
              explanation.visualize_feature_importance(
                  path, top_k=top_k
              )
      else:
          explanation.visualize_feature_importance(path, top_k=top_k)
          assert osp.exists(path)
  
file_path: pytorch_geometric/test/explain/test_hetero_explanation.py
imports: import os.path
  from typing import Optional, Union
  import pytest
  import torch
  from torch_geometric.data import HeteroData
  from torch_geometric.explain import HeteroExplanation
  from torch_geometric.explain.config import MaskType
  from torch_geometric.testing import withPackage
label_desc: Use image node_id 6 for calling a global function with example usage: test_visualize_feature_importance(top_k, node_mask_type, tmp_path, hetero_data) without return types