code: def to_np_format(self, data, flatten=True):
      if isinstance(data, list):
          ret = np.array(data)
      elif isinstance(data, torch.Tensor):
          ret = data.detach().cpu().numpy()
      elif isinstance(data, pd.Series) or isinstance(
          data, pd.DataFrame
      ):
          ret = np.array(data.values.tolist())
      else:
          ret = data
  
      if flatten:
          ret = ret.flatten()
  
      return ret.astype(np.float64)
  
imports: from typing import Dict
  from transformers import EvalPrediction
  from transformers.trainer_utils import PredictionOutput
  import pandas
  import torch
  import numpy
  from typing import Union
  import json
  import logging
label_desc: Use image node_id 3 for calling the Metric obj's underlying member method code with example usage: obj.to_np_format(data, flatten) and returns: ret