code: def _mock_parquet_dataset(partitions, arrow_schema):
      """Creates a pyarrow.ParquetDataset mock capable of returning:
  
          parquet_dataset.pieces[0].get_metadata(parquet_dataset.fs.open).schema.to_arrow_schema() == schema
          parquet_dataset.partitions = partitions
  
      :param partitions: expected to be a list of pa.parquet.PartitionSet
      :param arrow_schema: an instance of pa.arrow_schema to be assumed by the mock parquet dataset object.
      :return:
      """
      piece_mock = mock.Mock()
      piece_mock.get_metadata().schema.to_arrow_schema.return_value = (
          arrow_schema
      )
  
      dataset_mock = mock.Mock()
      type(dataset_mock).pieces = mock.PropertyMock(
          return_value=[piece_mock]
      )
      type(dataset_mock).partitions = partitions
  
      return dataset_mock
  
imports: from __future__ import division
  from decimal import Decimal
  import numpy
  import pyarrow
  import pyarrow.parquet
  import pytest
  from pyspark import Row
  from pyspark.sql.types import StringType, IntegerType, DecimalType, ShortType, LongType
  from petastorm.codecs import ScalarCodec, NdarrayCodec
  from petastorm.unischema import Unischema, UnischemaField, dict_to_spark_row, insert_explicit_nulls, match_unischema_fields, _new_gt_255_compatible_namedtuple, _fullmatch
  from unittest import mock
label_desc: Use image node_id 1 for calling a global function with example usage: _mock_parquet_dataset(partitions, arrow_schema) and returns: dataset_mock