code: def re_instantiate_sampler(sampler, new_sampler_class=None):
      all_attributes = vars(sampler)
      if new_sampler_class is not None:
          return new_sampler_class(**all_attributes)
      return type(sampler)(**all_attributes)
  
file_path: fastNLP/fastNLP/core/samplers/utils.py
imports: from array import array
  from typing import Sequence
  from collections import deque
label_desc: Use image node_id 1 for calling a global function with example usage: re_instantiate_sampler(sampler, new_sampler_class) and returns: type, new_sampler_class