class_docstr: A Metric is the base class and common API for all metrics.
  
  <Deprecated version="2.5.0">
  
  Use the new library 🤗 Evaluate instead: https://huggingface.co/docs/evaluate
  
  </Deprecated>
  
  Args:
      config_name (``str``): This is used to define a hash specific to a metrics computation script and prevents the metric's data
          to be overridden when the metric loading script is modified.
      keep_in_memory (:obj:`bool`): keep all predictions and references in memory. Not possible in distributed settings.
      cache_dir (``str``): Path to a directory in which temporary prediction/references data will be stored.
          The data directory should be located on a shared file-system in distributed setups.
      num_process (``int``): specify the total number of nodes in a distributed settings.
          This is useful to compute metrics in distributed setups (in particular non-additive metrics like F1).
      process_id (``int``): specify the id of the current process in a distributed setup (between 0 and num_process-1)
          This is useful to compute metrics in distributed setups (in particular non-additive metrics like F1).
      seed (:obj:`int`, optional): If specified, this will temporarily set numpy's random seed when :func:`datasets.Metric.compute` is run.
      experiment_id (``str``): A specific experiment id. This is used if several distributed evaluations share the same file system.
          This is useful to compute metrics in distributed setups (in particular non-additive metrics like F1).
      max_concurrent_cache_files (``int``): Max number of concurrent metrics cache files (default 10000).
      timeout (``Union[int, float]``): Timeout in second for distributed setting synchronization.
class_docstr_tok: ["A","Metric","is","the","base","class","and","common","API","for","all","metrics",".","<","Deprecated","version=","''","2.5.0","''",">","Use","the","new","library","\ud83e\udd17","Evaluate","instead",":","https",":","\/\/huggingface.co\/docs\/evaluate","<","\/Deprecated",">","Args",":","config_name","(","``","str","``",")",":","This","is","used","to","define","a","hash","specific","to","a","metrics","computation","script","and","prevents","the","metric","'s","data","to","be","overridden","when","the","metric","loading","script","is","modified",".","keep_in_memory","(",":","obj",":","`","bool","`",")",":","keep","all","predictions","and","references","in","memory",".","Not","possible","in","distributed","settings",".","cache_dir","(","``","str","``",")",":","Path","to","a","directory","in","which","temporary","prediction\/references","data","will","be","stored",".","The","data","directory","should","be","located","on","a","shared","file-system","in","distributed","setups",".","num_process","(","``","int","``",")",":","specify","the","total","number","of","nodes","in","a","distributed","settings",".","This","is","useful","to","compute","metrics","in","distributed","setups","(","in","particular","non-additive","metrics","like","F1",")",".","process_id","(","``","int","``",")",":","specify","the","id","of","the","current","process","in","a","distributed","setup","(","between","0","and","num_process-1",")","This","is","useful","to","compute","metrics","in","distributed","setups","(","in","particular","non-additive","metrics","like","F1",")",".","seed","(",":","obj",":","`","int","`",",","optional",")",":","If","specified",",","this","will","temporarily","set","numpy","'s","random","seed","when",":","func",":","`","datasets.Metric.compute","`","is","run",".","experiment_id","(","``","str","``",")",":","A","specific","experiment","id",".","This","is","used","if","several","distributed","evaluations","share","the","same","file","system",".","This","is","useful","to","compute","metrics","in","distributed","setups","(","in","particular","non-additive","metrics","like","F1",")",".","max_concurrent_cache_files","(","``","int","``",")",":","Max","number","of","concurrent","metrics","cache","files","(","default","10000",")",".","timeout","(","``","Union","[","int",",","float","]","``",")",":","Timeout","in","second","for","distributed","setting","synchronization","."]
code: def __init__(
      self,
      config_name: Optional[str] = None,
      keep_in_memory: bool = False,
      cache_dir: Optional[str] = None,
      num_process: int = 1,
      process_id: int = 0,
      seed: Optional[int] = None,
      experiment_id: Optional[str] = None,
      max_concurrent_cache_files: int = 10000,
      timeout: Union[int, float] = 100,
      **kwargs,
  ):
      # prepare info
      self.config_name = config_name or "default"
      info = self._info()
      info.metric_name = camelcase_to_snakecase(self.__class__.__name__)
      info.config_name = self.config_name
      info.experiment_id = experiment_id or "default_experiment"
      MetricInfoMixin.__init__(
          self, info
      )  # For easy access on low level
  
      # Safety checks on num_process and process_id
      if not isinstance(process_id, int) or process_id < 0:
          raise ValueError(
              "'process_id' should be a number greater than 0"
          )
      if not isinstance(num_process, int) or num_process <= process_id:
          raise ValueError(
              "'num_process' should be a number greater than process_id"
          )
      if keep_in_memory and num_process != 1:
          raise ValueError(
              "Using 'keep_in_memory' is not possible in distributed setting (num_process > 1)."
          )
  
      self.num_process = num_process
      self.process_id = process_id
      self.max_concurrent_cache_files = max_concurrent_cache_files
  
      self.keep_in_memory = keep_in_memory
      self._data_dir_root = os.path.expanduser(
          cache_dir or config.HF_METRICS_CACHE
      )
      self.data_dir = self._build_data_dir()
      if seed is None:
          _, seed, pos, *_ = np.random.get_state()
          self.seed: int = seed[pos] if pos < 624 else seed[0]
      else:
          self.seed: int = seed
      self.timeout: Union[int, float] = timeout
  
      # Update 'compute' and 'add' docstring
      # methods need to be copied otherwise it changes the docstrings of every instance
      self.compute = types.MethodType(copyfunc(self.compute), self)
      self.add_batch = types.MethodType(copyfunc(self.add_batch), self)
      self.add = types.MethodType(copyfunc(self.add), self)
      self.compute.__func__.__doc__ += self.info.inputs_description
      self.add_batch.__func__.__doc__ += self.info.inputs_description
      self.add.__func__.__doc__ += self.info.inputs_description
  
      # self.arrow_schema = pa.schema(field for field in self.info.features.type)
      self.buf_writer = None
      self.writer = None
      self.writer_batch_size = None
      self.data = None
  
      # This is the cache file we store our predictions/references in
      # Keep it None for now so we can (cloud)pickle the object
      self.cache_file_name = None
      self.filelock = None
      self.rendez_vous_lock = None
  
      # This is all the cache files on which we have a lock when we are in a distributed setting
      self.file_paths = None
      self.filelocks = None
  
imports: import os
  import types
  import uuid
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import pyarrow
  from filelock import BaseFileLock, Timeout
  from .None import config
  from .arrow_dataset import Dataset
  from .arrow_reader import ArrowReader
  from .arrow_writer import ArrowWriter
  from .download.download_config import DownloadConfig
  from .download.download_manager import DownloadManager
  from .features import Features
  from .info import DatasetInfo, MetricInfo
  from .naming import camelcase_to_snakecase
  from .utils._filelock import FileLock
  from .utils.deprecation_utils import deprecated
  from .utils.logging import get_logger
  from .utils.py_utils import copyfunc, temp_seed
label_desc: Use image node_id 1 to create a new Metric object from inherited base classes: MetricInfoMixin with example: obj = Metric(config_name, keep_in_memory, cache_dir, num_process, process_id, seed, experiment_id, max_concurrent_cache_files, timeout)