code: def _check(cls, name, val, can_be_zero=False, val_type=float):
      
      valid_types = [val_type]
      if val_type is float:
        valid_types.append(int)
  
      if type(val) not in valid_types:
        raise TypeError(
            'Expect type %s for parameter %s' % (val_type.__name__, name))
      if val < 0:
        raise ValueError(
            'Value for parameter %s has to be greater than 0' % name)
      if not can_be_zero and val == 0:
        raise ValueError(
            'Value for parameter %s can not be 0' % name)
      return val
docs: Check init arguments.
  
      Args:
        name: name of the argument. For logging purpose.
        val: value. Value has to be non negative number.
        can_be_zero: whether value can be zero.
        val_type: Python type of the value.
  
      Returns:
        The value.
  
      Raises:
        ValueError: when invalid value is passed in.
        TypeError: when invalid value type is passed in.