code: def _finite_env_factory(dataset, num_replicas, rank, complex=False):
      if complex:
          return lambda: FiniteEnvWithComplexObs(
              dataset, num_replicas, rank
          )
      return lambda: FiniteEnv(dataset, num_replicas, rank)
  
imports: from collections import Counter
  import gym
  import numpy
  from tianshou.data import Batch, Collector
  from tianshou.policy import BasePolicy
  from torch.utils.data import DataLoader, Dataset, DistributedSampler
  from qlib.rl.utils.finite_env import LogWriter, FiniteDummyVectorEnv, FiniteShmemVectorEnv, FiniteSubprocVectorEnv, check_nan_observation, generate_nan_observation
label_desc: Use image node_id 1 for calling a global function with example usage: _finite_env_factory(dataset, num_replicas, rank, complex) and returns: function, function