code: def eval_sample(self, sample: Any, *_):
      assert isinstance(sample, dict), "sample must be a dict"
      assert "text" in sample, "sample must have a text key"
      assert isinstance(
          sample["text"], str
      ), "sample text must be a string"
  
      payload = sample["text"]
      results = compression.run_eval(
          payload=payload,
          completion_fn=self.completion_fns[0],
          prompt_version=self.prompt_version,
          metadata=sample,
      )
  
      evals.record.record_metrics(
          compression_ratio=results["compression_ratio"],
          compression_ratio_cap1=results["compression_ratio_cap1"],
          reconstruction_error=results[
              self.reconstruction_error_metric
          ],
          character_error_rate_cap1=results[
              "character_error_rate_cap1"
          ],
          semantic_distance=results["semantic_distance"],
      )
  
file_path: evals/evals/elsuite/text_compression/eval.py
imports: import numpy
  from pyparsing import Any
  import evals
  import evals.elsuite.text_compression.compression
  import evals.metrics
  from evals.api import CompletionFn
  from evals.eval import Eval
  from evals.record import RecorderBase
label_desc: Use image node_id 2 for calling the TextCompression obj's underlying member method code with example usage: obj.eval_sample(sample) without return types