code: def _visualize_score(
      score: torch.Tensor,
      labels: List[str],
      path: Optional[str] = None,
      top_k: Optional[int] = None,
  ):
      import matplotlib.pyplot as plt
      import pandas as pd
  
      if len(labels) != score.numel():
          raise ValueError(
              f"The number of labels (got {len(labels)}) must "
              f"match the number of scores (got {score.numel()})"
          )
  
      score = score.cpu().numpy()
  
      df = pd.DataFrame({"score": score}, index=labels)
      df = df.sort_values("score", ascending=False)
      df = df.round(decimals=3)
  
      if top_k is not None:
          df = df.head(top_k)
          title = f"Feature importance for top {len(df)} features"
      else:
          title = f"Feature importance for {len(df)} features"
  
      ax = df.plot(
          kind="barh",
          figsize=(10, 7),
          title=title,
          ylabel="Feature label",
          xlim=[0, float(df["score"].max()) + 0.3],
          legend=False,
      )
      plt.gca().invert_yaxis()
      ax.bar_label(container=ax.containers[0], label_type="edge")
  
      if path is not None:
          plt.savefig(path)
      else:
          plt.show()
  
      plt.close()
  
imports: import copy
  from typing import Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch_geometric.data.data import Data, warn_or_raise
  from torch_geometric.data.hetero_data import HeteroData
  from torch_geometric.explain.config import ThresholdConfig, ThresholdType
  from torch_geometric.typing import EdgeType, NodeType
  from torch_geometric.visualization import visualize_graph
label_desc: Use image node_id 1 for calling a global function with example usage: _visualize_score(score, labels, path, top_k) without return types