def coerce(cls, string):
        """Create a :class:`Requirement` object from a given package spec."""
        match = re.match(cls.spec_regex, string)
        if not match:
            raise InvalidRequirementSpecError("could not parse requirement")
        package = match.group(1)
        if all(match.group(2, 3)):
            version = "".join(match.group(2, 3))
        else:
            version = None
        return cls(package, version)
def _model_variable_scope(self):
    """Returns a variable scope that the model should be created under.

    If self.dtype is a castable type, model variable will be created in fp32
    then cast to self.dtype before being used.

    Returns:
      A variable scope for the model.
    """

    return tf.compat.v1.variable_scope(
        'resnet_model',
        custom_getter=self._custom_dtype_getter,
        reuse=tf.AUTO_REUSE)