def METHOD_NAME(output_dir, filename, data, to_json = True, chunk_size = None):
    def write_to_file_inner(path, data, use_abs_value = True):
        with open(path, 'w') as f:
            print('vec_push![', file=f)
            for k, v in data:
                print('    (hex!("{}").into(), balance!({:.18f})),'.format(k, v), file=f)
            print(']', file=f)
    def write_to_json(path, data, use_abs_value = True):
        with open(path, 'w') as f:
            print('[', file=f)
            for i in range(len(data)):
                k, v = data[i]
                print('  {', file=f)
                print('    "address": "{}",'.format(k), file=f)
                print('    "amount": "{}"'.format(int(v * Decimal(10**18))), file=f)
                if i == len(data) - 1:
                    print('  }', file=f)
                else:
                    print('  },', file=f)
            print(']', file=f)
    if to_json:
        writer = write_to_json
        ext = 'json'
    else:
        writer = write_to_file_inner
        ext = 'in'
    if chunk_size is not None:
        num_chunks = len(data) // chunk_size
        if num_chunks * chunk_size < len(data):
            num_chunks += 1
        if num_chunks > 1:
            data_items = list(data.items())
            for i in range(num_chunks - 1):
                path = f'{output_dir}/{filename}.{i}.{ext}'
                writer(path, data_items[i * chunk_size:(i + 1) * chunk_size])
            writer(
                f'{output_dir}/{filename}.{num_chunks - 1}.{ext}',
                data_items[(num_chunks - 1) * chunk_size:]
            )
        else:
            writer(f'{output_dir}/{filename}.{ext}', list(data.items()))
    else:
        writer(f'{output_dir}/{filename}.{ext}', list(data.items()))