code: def smoothed_inference(
      batch,
      past_target,
      net,
      sigma,
      device,
      num_noised_samples: int = 100,
      intermediate_noise: float = None,
      retain_positivity: bool = True,
  ):
      outputs = []
  
      for _ in tqdm(range(num_noised_samples), leave=False):
          noised_past_target = change_device(past_target, device)
          noised_past_target += torch.normal(
              mean=torch.zeros(noised_past_target.shape, device=device),
              std=sigma * torch.abs(noised_past_target),
          )
          if retain_positivity:
              noised_past_target = torch.clamp(
                  noised_past_target, min=0
              )
  
          noised_inputs = {
              key: batch[key] for key in PREDICTION_INPUT_NAMES
          }
          noised_inputs["past_target_cdf"] = noised_past_target
  
          sample = net(**noised_inputs)
  
          outputs.append(sample.detach().cpu().numpy())
  
          del noised_past_target, noised_inputs, sample
          torch.cuda.empty_cache()
  
      return np.concatenate(outputs, axis=1)
  
imports: import json
  import pickle
  import random
  import torch
  import numpy
  import pandas
  from tqdm.auto import tqdm
  from typing import Iterator
  from gluonts.dataset.common import DataEntry, Dataset, ListDataset
label_desc: Use image node_id 1 for calling a global function with example usage: smoothed_inference(batch, past_target, net, sigma, device, num_noised_samples, intermediate_noise, retain_positivity) and returns: np