class_docstr: <<< WordCloud >>>
  
  Word cloud is to visually highlight the keywords that
  appear frequently in the text.
code: def _encode_image_to_base64(
      self, image_or_path: str
  ) -> types.Optional[str]:
      try:
          # 尝试判断是否为图片路径(base64 长度很长会导致 Pathlib 会异常)
          is_image_file = Path(image_or_path).is_file()
          is_image_file_exist = Path(image_or_path).exists()
          if is_image_file and is_image_file_exist:
              ext = Path(image_or_path).suffix[1:]
              if ext in self._mask_image_suffix:
                  with open(Path(image_or_path), "rb") as f:
                      data = base64.b64encode(f.read()).decode()
                      image_str = f"data:image/{ext};base64,{data}"
                  return image_str
      except OSError:
          return image_or_path
  
file_path: pyecharts/pyecharts/charts/basic_charts/wordcloud.py
imports: import base64
  import random
  from pathlib import Path
  from ...None import options
  from ...None import types
  from ...charts.chart import Chart
  from ...commons.utils import JsCode
  from ...exceptions import WordCloudMaskImageException
  from ...globals import ChartType
label_desc: Use image node_id 3 for calling the WordCloud obj's underlying member method code with example usage: obj._encode_image_to_base64(image_or_path) and returns: image_or_path, image_str