code: def test_pil_image_encoding(self):
      import _plotly_utils
  
      img_path = os.path.join(
          _plotly_utils.__path__[0],
          "tests",
          "resources",
          "1x1-black.png",
      )
  
      with open(img_path, "rb") as f:
          hex_bytes = base64.b64encode(f.read()).decode("ascii")
          expected_uri = "data:image/png;base64," + hex_bytes
  
      img = Image.open(img_path)
      j1 = _json.dumps({"source": img}, cls=utils.PlotlyJSONEncoder)
      assert j1 == '{"source": "%s"}' % expected_uri
  
imports: import datetime
  import math
  import decimal
  from datetime import datetime
  from unittest import TestCase
  from time import time
  import pytest
  import numpy
  import pandas
  import pytz
  from pandas.testing import assert_series_equal
  import json
  import os
  import base64
  from plotly import optional_imports, utils
  import plotly.graph_objects
  from plotly.graph_objs import Scatter, Scatter3d, Figure, Data
  from plotly.utils import get_by_path
  from PIL import Image
label_desc: Use image node_id 20 for calling the TestJSONEncoder obj's underlying member method code with example usage: obj.test_pil_image_encoding() without return types