class_docstr: Fréchet Audio Distance computation based on official TensorFlow implementation from Google Research.
  
  From: D.C. Dowson & B.V. Landau The Fréchet distance between
  multivariate normal distributions
  https://doi.org/10.1016/0047-259X(82)90077-X
  The Fréchet distance between two multivariate gaussians,
  `X ~ N(mu_x, sigma_x)` and `Y ~ N(mu_y, sigma_y)`, is `d^2`.
  d^2 = (mu_x - mu_y)^2 + Tr(sigma_x + sigma_y - 2 * sqrt(sigma_x*sigma_y))
      = (mu_x - mu_y)^2 + Tr(sigma_x) + Tr(sigma_y)
                      - 2 * Tr(sqrt(sigma_x*sigma_y)))
  
  To use this FAD computation metric, you need to have the proper Frechet Audio Distance tool setup
  from: https://github.com/google-research/google-research/tree/master/frechet_audio_distance
  We provide the below instructions as reference but we do not guarantee for further support
  in frechet_audio_distance installation. This was tested with python 3.10, cuda 11.8, tensorflow 2.12.0.
  
      We recommend installing the frechet_audio_distance library in a dedicated env (e.g. conda).
  
      1. Get the code and models following the repository instructions. We used the steps below:
              git clone git@github.com:google-research/google-research.git
              git clone git@github.com:tensorflow/models.git
              mkdir google-research/tensorflow_models
              touch google-research/tensorflow_models/__init__.py
              cp -r models/research/audioset google-research/tensorflow_models/
              touch google-research/tensorflow_models/audioset/__init__.py
              echo "from .vggish import mel_features, vggish_params, vggish_slim" >                     google-research/tensorflow_models/audioset/__init__.py
              # we can now remove the tensorflow models repository
              # rm -r models
              cd google-research
         Follow the instructions to download the vggish checkpoint. AudioCraft base configuration
         assumes it is placed in the AudioCraft reference dir.
  
         Note that we operate the following changes for the code to work with TensorFlow 2.X and python 3:
         - Update xrange for range in:
           https://github.com/google-research/google-research/blob/master/frechet_audio_distance/audioset_model.py
         - Update `tf_record = tf.python_io.tf_record_iterator(filename).next()` to
           `tf_record = tf.python_io.tf_record_iterator(filename).__next__()` in
            https://github.com/google-research/google-research/blob/master/frechet_audio_distance/fad_utils.py
         - Update `import vggish_params as params` to `from . import vggish_params as params` in:
           https://github.com/tensorflow/models/blob/master/research/audioset/vggish/vggish_slim.py
         - Add flag to provide a given batch size for running the AudioSet model in:
           https://github.com/google-research/google-research/blob/master/frechet_audio_distance/create_embeddings_main.py
           ```
           flags.DEFINE_integer('batch_size', 64,
                                'Number of samples in the batch for AudioSet model.')
           ```
           Ensure you pass the flag to the create_embeddings_beam.create_pipeline function, adding:
           `batch_size=FLAGS.batch_size` to the provided parameters.
  
      2. Follow instructions for the library installation and a valid TensorFlow installation
         ```
         # e.g. instructions from: https://www.tensorflow.org/install/pip
         conda install -c conda-forge cudatoolkit=11.8.0
         python3 -m pip install nvidia-cudnn-cu11==8.6.0.163 tensorflow==2.12.*
         mkdir -p $CONDA_PREFIX/etc/conda/activate.d
         echo 'CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))'              >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
         echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib'              >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
         source $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
         # Verify install: on a machine with GPU device
         python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
         ```
  
         Now install frechet_audio_distance required dependencies:
         ```
         # We assume we already have TensorFlow installed from the above steps
         pip install apache-beam numpy scipy tf_slim
         ```
  
         Finally, follow remaining library instructions to ensure you have a working frechet_audio_distance setup
         (you may want to specify --model_ckpt flag pointing to the model's path).
  
      3. AudioCraft's FrechetAudioDistanceMetric requires 2 environment variables pointing to the python executable
         and Tensorflow library path from the above installation steps:
          export TF_PYTHON_EXE="<PATH_TO_THE_ENV_PYTHON_BINARY>"
          export TF_LIBRARY_PATH="<PATH_TO_THE_ENV_CUDNN_LIBRARY>"
  
          e.g. assuming we have installed everything in a dedicated conda env
          with python 3.10 that is currently active:
          export TF_PYTHON_EXE="$CONDA_PREFIX/bin/python"
          export TF_LIBRARY_PATH="$CONDA_PREFIX/lib/python3.10/site-packages/nvidia/cudnn/lib"
  
          Finally you may want to export the following variable:
          export TF_FORCE_GPU_ALLOW_GROWTH=true
          See: https://www.tensorflow.org/guide/gpu#limiting_gpu_memory_growth
  
          You can save those environment variables in your training conda env, when currently active:
          `$CONDA_PREFIX/etc/conda/activate.d/env_vars.sh`
          e.g. assuming the env with TensorFlow and frechet_audio_distance install is named ac_eval,
          and the training conda env is named audiocraft:
          ```
          # activate training env
          conda activate audiocraft
          # get path to all envs
          CONDA_ENV_DIR=$(dirname $CONDA_PREFIX)
          # export pointers to evaluation env for using TensorFlow in FrechetAudioDistanceMetric
          touch $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
          echo 'export TF_PYTHON_EXE="$CONDA_ENV_DIR/ac_eval/bin/python"' >>                 $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
          echo 'export TF_LIBRARY_PATH="$CONDA_ENV_DIR/ac_eval/lib/python3.10/site-packages/nvidia/cudnn/lib"' >>                 $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
          # optionally:
          echo 'export TF_FORCE_GPU_ALLOW_GROWTH=true' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
          # you may need to reactivate the audiocraft env for this to take effect
          ```
  
  Args:
      bin (Path or str): Path to installed frechet audio distance code.
      model_path (Path or str): Path to Tensorflow checkpoint for the model
          used to compute statistics over the embedding beams.
      format (str): Audio format used to save files.
      log_folder (Path or str, optional): Path where to write process logs.
code: def _sequential_create_embedding_beams(self):
      logger.info("Creating embeddings beams in a sequential manner")
      (
          tests_beams_process,
          tests_beams_log_file,
      ) = self._create_embedding_beams(is_background=False)
      tests_beams_code = tests_beams_process.wait()
      self._log_process_result(
          tests_beams_code, tests_beams_log_file, is_background=False
      )
      (
          bg_beams_process,
          bg_beams_log_file,
      ) = self._create_embedding_beams(is_background=True)
      bg_beams_code = bg_beams_process.wait()
      self._log_process_result(
          bg_beams_code, bg_beams_log_file, is_background=True
      )
  
imports: import logging
  from pathlib import Path
  import os
  import subprocess
  import tempfile
  import typing
  from audiocraft.data.audio import audio_write
  from audiocraft.data.audio_utils import convert_audio
  import flashy
  import torch
  import torchmetrics
  from ..environment import AudioCraftEnvironment
label_desc: Use image node_id 9 for calling the FrechetAudioDistanceMetric obj's underlying member method code with example usage: obj._sequential_create_embedding_beams() without return types