Q:

How to include function attributes inside a class?

class c():

    def foo(self):
        self.foo.loss1 = 20
        return(50)

prob = c()
l1 = prob.foo.loss1

print(l1)

l1 = prob.foo.loss1
AttributeError: 'function' object has no attribute 'loss1'

A:

Your class construction is not right here. So, you are trying to take in two input numbers and return their summation via method foo. Let's make a Klass that satiates your intent here.
class Klass:
    def __init__(self, loss1, loss2):
       """Take input and initialize your class."""

        self.loss1 = loss1
        self.loss2 = loss2

    def foo(self):
        """Method that returns summation of the inputs."""

        return self.loss1 + self.loss2

Now use the class like this:
# making an instance of your class
l1 = Klass(loss1=20, loss2=30)

# calling the foo method and printing the result
print(l1.foo())

This shows:
>> 50

