code: def get_dataloader(
      dataset,
      use_dataloader,
      sampler,
      batch_size,
      shuffle,
      drop_last=False,
  ):
      """
      :param dataset:
      :param use_dataloader: 是否使用 JittorDataLoader 包裹
      :param sampler: 使用 BatchSampler Samlper 还是不使用 Sampler
      """
      if use_dataloader:
          dataloader = JittorDataLoader(
              dataset,
              batch_size=batch_size,
              shuffle=shuffle,
              drop_last=drop_last,
          )
          dataloader.dataset.set_attrs(sampler=sampler)
      else:
          dataloader = dataset
          dataloader.set_attrs(
              batch_size=batch_size,
              shuffle=shuffle,
              drop_last=drop_last,
              sampler=sampler,
          )
  
      return dataloader
  
imports: import pytest
  from copy import deepcopy
  from pathlib import Path
  from fastNLP.core.drivers.jittor_driver import JittorSingleDriver
  from fastNLP.core.samplers import ReproduceBatchSampler, RandomSampler
  from fastNLP.core.dataloaders import JittorDataLoader
  from tests.helpers.models.jittor_model import JittorNormalModel_Classification_1
  from tests.helpers.datasets.jittor_data import JittorNormalDataset, JittorNormalXYDataset
  from tests.helpers.datasets.torch_data import TorchNormalDataset
  from tests.helpers.models.torch_model import TorchNormalModel_Classification_1
  from fastNLP.envs.distributed import rank_zero_rm
  from fastNLP.envs.imports import _NEED_IMPORT_JITTOR, _NEED_IMPORT_TORCH
label_desc: Use image node_id 1 for calling a global function with example usage: get_dataloader(dataset, use_dataloader, sampler, batch_size, shuffle, drop_last) and returns: dataloader