docstr: Input:
  3D-array: for each step, for each word contains an embedding vector
      [array([[-1.94962081e-02,  4.01699156e-01, -7.21625937e-03, ...,
              3.15075251e-03, -1.78157743e-02, -4.47794721e-02],
          ...,
          [-1.24082603e-01,  6.57148898e-01, -6.30941940e-03, ...,
              4.67915349e-02, -1.91840027e-02, -1.02941066e-01]], dtype=float32)
      array([[ 1.39849812e-01,  1.83899269e-01,  6.99776178e-03, ...,
              7.79140592e-02, -1.22751370e-01,  4.21638079e-02],
          ...,
          [ 1.30717367e-01, -4.97479558e-01, -8.03395808e-02, ...,
              -4.52864505e-02, -2.93156672e-02,  3.58024091e-02]], dtype=float32)]
      Returns:
          max_{t=1..n}(max_{k=0..t-1}[ RA(y_t -> y_k) ])
  
  OR
  2D-array: for each step, sentence embedding
docstr_tok: ["Input",":","3D-array",":","for","each","step",",","for","each","word","contains","an","embedding","vector","[","array","(","[","[","-1.94962081e-02",",","4.01699156e-01",",","-7.21625937e-03",",","...",",","3.15075251e-03",",","-1.78157743e-02",",","-4.47794721e-02","]",",","...",",","[","-1.24082603e-01",",","6.57148898e-01",",","-6.30941940e-03",",","...",",","4.67915349e-02",",","-1.91840027e-02",",","-1.02941066e-01","]","]",",","dtype=float32",")","array","(","[","[","1.39849812e-01",",","1.83899269e-01",",","6.99776178e-03",",","...",",","7.79140592e-02",",","-1.22751370e-01",",","4.21638079e-02","]",",","...",",","[","1.30717367e-01",",","-4.97479558e-01",",","-8.03395808e-02",",","...",",","-4.52864505e-02",",","-2.93156672e-02",",","3.58024091e-02","]","]",",","dtype=float32",")","]","Returns",":","max_","{","t=1","..","n","}","(","max_","{","k=0","..","t-1","}","[","RA","(","y_t","-",">","y_k",")","]",")","OR","2D-array",":","for","each","step",",","sentence","embedding"]
code: def repetitions(self, embeddings: np.array) -> float:
      """Input:
      3D-array: for each step, for each word contains an embedding vector
          [array([[-1.94962081e-02,  4.01699156e-01, -7.21625937e-03, ...,
                  3.15075251e-03, -1.78157743e-02, -4.47794721e-02],
              ...,
              [-1.24082603e-01,  6.57148898e-01, -6.30941940e-03, ...,
                  4.67915349e-02, -1.91840027e-02, -1.02941066e-01]], dtype=float32)
          array([[ 1.39849812e-01,  1.83899269e-01,  6.99776178e-03, ...,
                  7.79140592e-02, -1.22751370e-01,  4.21638079e-02],
              ...,
              [ 1.30717367e-01, -4.97479558e-01, -8.03395808e-02, ...,
                  -4.52864505e-02, -2.93156672e-02,  3.58024091e-02]], dtype=float32)]
          Returns:
              max_{t=1..n}(max_{k=0..t-1}[ RA(y_t -> y_k) ])
  
      OR
      2D-array: for each step, sentence embedding
      """
      assert len(embeddings) > 1
      words = False
      if len(embeddings[0].shape) == 2:
          words = True
      ra_most_similar_with_previous = []
      # compare steps' word embedding alignments
      for i in range(1, len(embeddings)):
          ra = 0
          # some embeddings can be empty. For example, for latex-style equations
          if len(embeddings[i]) > 0:
              # most similar sentence among previous sentences
              for j in range(i):
                  if len(embeddings[j]) > 0:
                      # word embeddings
                      if words:
                          ra = max(
                              ra,
                              al_mean(
                                  embedding_alignment(
                                      embeddings[j], embeddings[i]
                                  )
                              ),
                          )
                      # sentence embeddings
                      else:
                          ra = max(
                              ra,
                              cosine_similarity_scaled(
                                  embeddings[j], embeddings[i]
                              ),
                          )
  
          ra_most_similar_with_previous.append(ra)
  
      return max(ra_most_similar_with_previous)
  
imports: from collections import defaultdict
  import itertools
  import math
  import numpy
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from tqdm import tqdm
  from projects.roscoe.utils import cosine_similarity_scaled, embedding_alignment, al_mean
label_desc: Use image node_id 14 for calling the Evaluator obj's underlying member method code with example usage: obj.repetitions(embeddings) and returns: max