code: def make_compatibility_workloads(
      core_context: core.Context,
      env: det.EnvContext,
      global_batch_size: int,
  ) -> Tuple[workload.Stream, Optional[WorkloadSequencer]]:
      """
      make_compatibility_workloads will create a stream of workloads to allow a pre-push-architecture
      TrialController train in a push-architecture world, by imitating the exact workloads that would
      have been generated by the pre-push master.
      """
  
      if core_context.distributed.get_rank() == 0:
          wlsq = WorkloadSequencer(
              core_context, env, global_batch_size
          )  # type: Optional[WorkloadSequencer]
      else:
          wlsq = None
  
      def workloads() -> workload.Stream:
          if wlsq:
              # Workloads are generated only on the chief worker.
              for wkld, response_fn in wlsq:
                  # Distribute to peers.
                  _ = core_context.distributed.broadcast(wkld)
                  # Process workload.
                  yield wkld, response_fn
                  # Wait for peers.
                  _ = core_context.distributed.gather(None)
              # Break the workers out of their loop.
              _ = core_context.distributed.broadcast(None)
          else:
              while True:
                  # Wait for chief to broadcast workload.
                  wkld = core_context.distributed.broadcast(None)
                  if wkld is None:
                      break
                  # Process workload.
                  yield wkld, lambda _: None
                  # Tell chief we finished.
                  _ = core_context.distributed.gather(None)
  
      return workloads(), wlsq
  
imports: import logging
  import sys
  from typing import Any, Generator, Optional, Tuple
  import determined
  from determined import core, util, workload
  from determined.common import check
label_desc: Use image node_id 2 for calling a global function with example usage: make_compatibility_workloads(core_context, env, global_batch_size) and returns: workloads,  wlsq