code: def test_path_partition_encoder_directory(fs, base_dir):
      path_partition_encoder = PathPartitionEncoder.of(
          style=PartitionStyle.DIRECTORY,
          field_names=["foo", "bar"],
          base_dir=base_dir,
          filesystem=fs,
      )
      _verify_resolved_paths_and_filesystem(
          path_partition_encoder.scheme
      )
      partition_values = ["1", "2"]
      partition_path = path_partition_encoder(partition_values)
      assert partition_path == posixpath.join(
          path_partition_encoder.scheme.normalized_base_dir,
          *partition_values,
      )
      if fs is not None:
          file_info = fs.get_file_info(partition_path)
          assert file_info.type == FileType.NotFound
          fs.create_dir(partition_path)
          file_info = fs.get_file_info(partition_path)
          assert file_info.type == FileType.Directory
      path_partition_encoder = PathPartitionEncoder.of(
          style=PartitionStyle.DIRECTORY,
          base_dir=base_dir,
          filesystem=fs,
      )
      partition_path = path_partition_encoder([])
      assert (
          partition_path
          == path_partition_encoder.scheme.normalized_base_dir
      )
      partition_path = path_partition_encoder(partition_values)
      assert partition_path == posixpath.join(
          path_partition_encoder.scheme.normalized_base_dir,
          *partition_values,
      )
  
imports: import json
  import os
  import posixpath
  from typing import Any, Callable, Dict, Iterator, List, Optional, Union
  import pandas
  import pyarrow
  import pyarrow
  import pytest
  from pyarrow.fs import FileType
  from pytest_lazyfixture import lazy_fixture
  import ray
  from ray.data.block import Block
  from ray.data.dataset import Dataset
  from ray.data.datasource import FileBasedDatasource, PathPartitionParser
  from ray.data.datasource.file_based_datasource import FileExtensionFilter, _resolve_paths_and_filesystem
  from ray.data.datasource.partitioning import Partitioning, PartitionStyle, PathPartitionFilter
  from ray.data.tests.conftest import *
  from ray.tests.conftest import *
label_desc: Use image node_id 9 for calling a global function with example usage: test_path_partition_encoder_directory(fs, base_dir) without return types