code: def _do_predictions(
      texts,
      melodies,
      duration,
      progress=False,
      gradio_progress=None,
      **gen_kwargs,
  ):
      MODEL.set_generation_params(duration=duration, **gen_kwargs)
      print(
          "new batch",
          len(texts),
          texts,
          [None if m is None else (m[0], m[1].shape) for m in melodies],
      )
      be = time.time()
      processed_melodies = []
      target_sr = 32000
      target_ac = 1
      for melody in melodies:
          if melody is None:
              processed_melodies.append(None)
          else:
              sr, melody = (
                  melody[0],
                  torch.from_numpy(melody[1])
                  .to(MODEL.device)
                  .float()
                  .t(),
              )
              if melody.dim() == 1:
                  melody = melody[None]
              melody = melody[..., : int(sr * duration)]
              melody = convert_audio(melody, sr, target_sr, target_ac)
              processed_melodies.append(melody)
  
      try:
          if any(m is not None for m in processed_melodies):
              outputs = MODEL.generate_with_chroma(
                  descriptions=texts,
                  melody_wavs=processed_melodies,
                  melody_sample_rate=target_sr,
                  progress=progress,
                  return_tokens=USE_DIFFUSION,
              )
          else:
              outputs = MODEL.generate(
                  texts, progress=progress, return_tokens=USE_DIFFUSION
              )
      except RuntimeError as e:
          raise gr.Error("Error while generating " + e.args[0])
      if USE_DIFFUSION:
          if gradio_progress is not None:
              gradio_progress(1, desc="Running MultiBandDiffusion...")
          tokens = outputs[1]
          if isinstance(
              MODEL.compression_model, InterleaveStereoCompressionModel
          ):
              (
                  left,
                  right,
              ) = MODEL.compression_model.get_left_right_codes(tokens)
              tokens = torch.cat([left, right])
          outputs_diffusion = MBD.tokens_to_wav(tokens)
          if isinstance(
              MODEL.compression_model, InterleaveStereoCompressionModel
          ):
              assert outputs_diffusion.shape[1] == 1  # output is mono
              outputs_diffusion = rearrange(
                  outputs_diffusion, "(s b) c t -> b (s c) t", s=2
              )
          outputs = torch.cat([outputs[0], outputs_diffusion], dim=0)
      outputs = outputs.detach().cpu().float()
      pending_videos = []
      out_wavs = []
      for output in outputs:
          with NamedTemporaryFile(
              "wb", suffix=".wav", delete=False
          ) as file:
              audio_write(
                  file.name,
                  output,
                  MODEL.sample_rate,
                  strategy="loudness",
                  loudness_headroom_db=16,
                  loudness_compressor=True,
                  add_suffix=False,
              )
              pending_videos.append(
                  pool.submit(make_waveform, file.name)
              )
              out_wavs.append(file.name)
              file_cleaner.add(file.name)
      out_videos = [
          pending_video.result() for pending_video in pending_videos
      ]
      for video in out_videos:
          file_cleaner.add(video)
      print("batch finished", len(texts), time.time() - be)
      print("Tempfiles currently stored: ", len(file_cleaner.files))
      return out_videos, out_wavs
  
imports: import argparse
  from concurrent.futures import ProcessPoolExecutor
  import logging
  import os
  from pathlib import Path
  import subprocess
  import sys
  from tempfile import NamedTemporaryFile
  import time
  import typing
  import warnings
  from einops import rearrange
  import torch
  import gradio
  from audiocraft.data.audio_utils import convert_audio
  from audiocraft.data.audio import audio_write
  from audiocraft.models.encodec import InterleaveStereoCompressionModel
  from audiocraft.models import MusicGen, MultiBandDiffusion
label_desc: Use image node_id 6 for calling a global function with example usage: _do_predictions(texts, melodies, duration, progress, gradio_progress) and returns: out_videos,  out_wavs