code: def create_random_explanation(
      hetero_data: HeteroData,
      node_mask_type: Optional[Union[MaskType, str]] = None,
      edge_mask_type: Optional[Union[MaskType, str]] = None,
  ):
      if node_mask_type is not None:
          node_mask_type = MaskType(node_mask_type)
      if edge_mask_type is not None:
          edge_mask_type = MaskType(edge_mask_type)
  
      out = HeteroExplanation()
  
      for key in ["paper", "author"]:
          out[key].x = hetero_data[key].x
          if node_mask_type == MaskType.object:
              out[key].node_mask = torch.rand(
                  hetero_data[key].num_nodes, 1
              )
          elif node_mask_type == MaskType.common_attributes:
              out[key].node_mask = torch.rand(
                  1, hetero_data[key].num_features
              )
          elif node_mask_type == MaskType.attributes:
              out[key].node_mask = torch.rand_like(hetero_data[key].x)
  
      for key in [("paper", "paper"), ("paper", "author")]:
          out[key].edge_index = hetero_data[key].edge_index
          out[key].edge_attr = hetero_data[key].edge_attr
          if edge_mask_type == MaskType.object:
              out[key].edge_mask = torch.rand(
                  hetero_data[key].num_edges
              )
  
      return out
  
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 1 for calling a global function with example usage: create_random_explanation(hetero_data, node_mask_type, edge_mask_type) and returns: out