code: def loader_factory():
      def train_loader(
          dataset: Dataset,
          prediction_interval_length: float,
          context_interval_length: float,
          is_train: bool = True,
          override_args: dict = None,
      ) -> Iterable[DataBatch]:
          if override_args is None:
              override_args = {}
  
          if is_train:
              sampler = ContinuousTimeUniformSampler(
                  num_instances=10,
                  min_past=context_interval_length,
                  min_future=prediction_interval_length,
              )
          else:
              sampler = ContinuousTimePredictionSampler(
                  min_past=context_interval_length
              )
  
          splitter = ContinuousTimeInstanceSplitter(
              future_interval_length=prediction_interval_length,
              past_interval_length=context_interval_length,
              instance_sampler=sampler,
              freq=to_offset("H"),
          )
  
          kwargs = dict(
              dataset=dataset,
              transform=splitter,
              batch_size=10,
              stack_fn=partial(
                  batchify, dtype=np.float32, variable_length=True
              ),
          )
  
          kwargs.update(override_args)
  
          if is_train:
              return itertools.islice(
                  TrainDataLoader(**kwargs), NUM_BATCHES
              )
          else:
              return InferenceDataLoader(**kwargs)
  
      return train_loader
  
imports: import itertools
  from functools import partial
  from typing import Iterable
  import numpy
  from pandas.tseries.frequencies import to_offset
  import pytest
  from gluonts.dataset.common import Dataset
  from gluonts.dataset.loader import DataBatch, InferenceDataLoader, TrainDataLoader
  from gluonts.mx.batchify import _pad_arrays, batchify, stack
  from gluonts.testutil.dummy_datasets import get_dataset
  from gluonts.transform import ContinuousTimeInstanceSplitter, ContinuousTimeUniformSampler, ContinuousTimePredictionSampler
label_desc: Use image node_id 1 for calling a global function with example usage: loader_factory() and returns: train_loader, itertools, InferenceDataLoader