code: def energy_value(h: List[Union[int, float]],
                   J: Dict[Tuple[int, int], Union[int, float]],
                   sol: List[int]) -> Union[int, float]:
      
      ener_ising = 0
      for elm in J.keys():
          if elm[0] == elm[1]:
              raise TypeError("""Interaction term must connect two different variables""")
          else:
              ener_ising += J[elm] * int(sol[elm[0]]) * int(sol[elm[1]])
      for i in range(len(h)):
          ener_ising += h[i] * int(sol[i])
      return ener_ising
docs: Obtain energy of an Ising solution for a given Ising problem (h,J).
  
      :param h: External magnetic term of the Ising problem.
      :param J: Interaction term of the Ising problem.
      :param sol: Ising solution.
      :return: Energy of the Ising string.