class_docstr: Class for parsing hyperparameters
class_docstr_tok: ["Class","for","parsing","hyperparameters"]
code: def _parse_opt(self, param_name, range_str):
      unbounded = is_log = rand_init = False
      min_range = max_range = array_length = None
      raw_fields = range_str.split(":")
  
      correct_format = True
      flags = ""
      if len(raw_fields) > 2:
          flags = raw_fields[-1]
          allowed_flags = "ualr"
          for letter in flags:
              if (
                  letter not in allowed_flags
                  or flags.count(letter) != 1
              ):
                  correct_format = False
          proper_field_length = 4 if "a" in flags else 3
          if len(raw_fields) != proper_field_length:
              correct_format = False
      elif len(raw_fields) < 2:
          correct_format = False
  
      if not correct_format:
          raise ValueError(
              "Hyperparameter flags (%s) are incorrect for %s"
              % (range_str, self.runner_args.optimizer)
          )
  
      try:
          min_range = float(raw_fields[0])
          max_range = float(raw_fields[1])
          array_length = int(raw_fields[2]) if "a" in flags else None
          if array_length is not None and array_length <= 0:
              raise ValueError
      except ValueError:
          raise ValueError(
              "Hyperparameter values (%s) are incorrect for %s"
              % (range_str, self.runner_args.optimizer)
          )
  
      if min_range > max_range:
          raise ValueError(
              "Min range (%s) is larger than max range (%s) "
              % (min_range, max_range)
          )
  
      unbounded = True if "u" in flags else False
      rand_init = True if "r" in flags else False
      if "l" in flags:
          is_log = True
          min_range = math.log(min_range)
          max_range = math.log(max_range)
      else:
          is_log = False
  
      if not hasattr(self, "index"):
          self.index = 0
      h = Hyperparameter(
          param_name,
          index=self.index,
          min_range=min_range,
          max_range=max_range,
          array_length=array_length,
          unbounded=unbounded,
          is_log=is_log,
          rand_init=rand_init,
      )
      self.index += array_length if array_length is not None else 1
      return h
  
file_path: studio/studio/hyperparameter.py
imports: import itertools
  import math
  import numpy
label_desc: Use image node_id 4 for calling the HyperparameterParser obj's underlying member method code with example usage: obj._parse_opt(param_name, range_str) and returns: h