code: def run_streaming_mcmc(
      data,
      kernel,
      num_samples,
      warmup_steps=None,
      initial_params=None,
      num_chains=1,
      hook_fn=None,
      mp_context=None,
      transforms=None,
      num_draws=None,
      group_by_chain=False,
  ):
      mcmc = StreamingMCMC(
          kernel=kernel,
          num_samples=num_samples,
          warmup_steps=warmup_steps,
          initial_params=initial_params,
          statistics=StatsOfDict(default=StackStats),
          num_chains=num_chains,
          hook_fn=hook_fn,
          transforms=transforms,
      )
      mcmc.run(data)
      statistics = mcmc.get_statistics(group_by_chain=group_by_chain)
  
      if group_by_chain:
          samples = {}
          agg = {}
          for (_, name), stat in statistics.items():
              if name in agg:
                  agg[name].append(stat["samples"])
              else:
                  agg[name] = [stat["samples"]]
          for name, l in agg.items():
              samples[name] = torch.stack(l)
      else:
          samples = {
              name: stat["samples"] for name, stat in statistics.items()
          }
  
      samples = select_samples(samples, num_draws, group_by_chain)
  
      if not group_by_chain:
          samples = {
              name: stat.unsqueeze(-1) for name, stat in samples.items()
          }
  
      return samples, mcmc.num_chains
  
imports: import os
  from functools import partial
  import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer.mcmc import HMC, NUTS
  from pyro.infer.mcmc.api import MCMC, StreamingMCMC, _MultiSampler, _UnarySampler
  from pyro.infer.mcmc.mcmc_kernel import MCMCKernel
  from pyro.infer.mcmc.util import initialize_model, select_samples
  from pyro.ops.streaming import StackStats, StatsOfDict
  from pyro.util import optional
  from tests.common import assert_close
label_desc: Use image node_id 3 for calling a global function with example usage: run_streaming_mcmc(data, kernel, num_samples, warmup_steps, initial_params, num_chains, hook_fn, mp_context, transforms, num_draws, group_by_chain) and returns: samples,  mcmc