def _ReplaceByOuterIfNecessary(self, item, substitutions):
    'Potentially replace a function type param with a class type param.\n\n    Args:\n      item: A pytd.TemplateItem\n      substitutions: A dictionary to update with what we replaced.\n    Returns:\n      Either [item] or [].\n    '
    containing_union = self._AllContaining(item.type_param)
    if (not containing_union):
        return [item]
    class_type_parameters = [type_param for type_param in containing_union if self.IsClassTypeParameter(type_param)]
    if class_type_parameters:
        substitutions[item.type_param] = pytd_utils.JoinTypes(class_type_parameters)
        return []
    else:
        return [item]
Potentially replace a function type param with a class type param.

Args:
  item: A pytd.TemplateItem
  substitutions: A dictionary to update with what we replaced.
Returns:
  Either [item] or [].
def _ReplaceByOuterIfNecessary(self, item, substitutions):
    'Potentially replace a function type param with a class type param.\n\n    Args:\n      item: A pytd.TemplateItem\n      substitutions: A dictionary to update with what we replaced.\n    Returns:\n      Either [item] or [].\n    '
    containing_union = self._AllContaining(item.type_param)
    if (not containing_union):
        return [item]
    class_type_parameters = [type_param for type_param in containing_union if self.IsClassTypeParameter(type_param)]
    if class_type_parameters:
        substitutions[item.type_param] = pytd_utils.JoinTypes(class_type_parameters)
        return []
    else:
        return [item]