code: def add_in_key_stat(action_note, stat_dict, key=None):
      """Determines whether the note played was in key, and updates a stat dict.
  
      Args:
        action_note: An integer representing the chosen action.
        stat_dict: A dictionary containing fields for statistics about
          compositions.
        key: The numeric values of notes belonging to this key. Defaults to
          C-major if not provided.
      Returns:
        A dictionary of composition statistics with 'notes_not_in_key' field
        updated.
      """
      if key is None:
          key = rl_tuner_ops.C_MAJOR_KEY
  
      if action_note not in key:
          stat_dict["notes_not_in_key"] += 1
  
      return stat_dict
  
file_path: magenta/magenta/models/rl_tuner/rl_tuner_eval_metrics.py
imports: from magenta.models.rl_tuner import rl_tuner_ops
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 6 for calling a global function with example usage: add_in_key_stat(action_note, stat_dict, key) and returns: stat_dict