code: def get_objective(self, sampler):
          
          def objective(params):
              circuit = self.get_circuit(params)
              circuit.make_cache()
              return self.get_energy(circuit, sampler)
          return objective
docs: Get an objective function to be optimized.