code: def lorenz_system_log_likelihood_fn(
      params,
      observed_values,
      observation_scale,
      observation_index,
      observation_mask,
      use_markov_chain=False,
      dtype=tf.float32,
  ):
      """Likelihood of a series under the Lorenz System model."""
      if observation_scale is None:  # Scales are random variables.
          (_, observation_scale) = params[:2]
          params = params[2] if use_markov_chain else params[2:]
      observed_values = tensor_util.convert_nonref_to_tensor(
          observed_values, name="observation_values", dtype=dtype
      )
      observation_scale = tensor_util.convert_nonref_to_tensor(
          observation_scale, name="observation_scale", dtype=dtype
      )
      num_observations = tf.compat.dimension_value(
          observed_values.shape[0]
      )
      observation_indices = list(
          np.arange(num_observations)[observation_mask]
      )
      series_values = (
          params if use_markov_chain else tf.stack(params, axis=-2)
      )[..., observation_index]
      masked_series = tf.gather(
          series_values, observation_indices, axis=-1
      )
      masked_observations = tf.gather(
          observed_values, observation_indices, axis=-1
      )
  
      return tfd.Independent(
          tfd.Normal(masked_series, observation_scale[..., tf.newaxis]),
          reinterpreted_batch_ndims=1,
      ).log_prob(masked_observations)
  
imports: import functools
  import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import tensor_util
  from inference_gym.internal import data
  from inference_gym.targets import bayesian_model
  from inference_gym.targets import model
  from inference_gym.targets.ground_truth import convection_lorenz_bridge
  from inference_gym.targets.ground_truth import convection_lorenz_bridge_unknown_scales
label_desc: Use image node_id 5 for calling a global function with example usage: lorenz_system_log_likelihood_fn(params, observed_values, observation_scale, observation_index, observation_mask, use_markov_chain, dtype) and returns: tfd