code: def write(self, data, metadata: Optional[Dict] = None):
      self.artifact.consumed()
      path = Path(self.artifact.uri.path)
      path.parent.mkdir(parents=True, exist_ok=True)
      with path.open("w") as fw:
          json.dump(data, fw)
  
      if metadata is not None:
          self.artifact.metadata.metadata = metadata
  
imports: import json
  import logging
  import typing
  from pathlib import Path
  from typing import Dict, Optional, Union
  import requests
  from fate.components.core.essential import JsonMetricArtifactType
  from .._base_type import URI, ArtifactDescribe, Metadata, MetricOutputMetadata, _ArtifactType, _ArtifactTypeWriter
label_desc: Use image node_id 1 for calling the JsonMetricFileWriter obj's underlying member method code with example usage: obj.write(data, metadata) without return types