code: def get_cost(self, *args, **kwargs):
          
  
          # Check if the cost should be calculated
          if self._iteration % self._cost_interval:
  
              test_result = False
  
          else:
  
              if self._verbose:
                  print(' - ITERATION:', self._iteration)
  
              # Calculate the current cost
              self.cost = self._calc_cost(verbose=self._verbose, *args, **kwargs)
              self._cost_list.append(self.cost)
  
              if self._verbose:
                  print(' - COST:', self.cost)
                  print('')
  
              # Test for convergence
              test_result = self._check_cost()
  
          # Update the current iteration number
          self._iteration += 1
  
          return test_result
docs: Get cost function
  
          This method calculates the current cost and tests for convergence
  
          Returns
          -------
          bool result of the convergence test