<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_by_code(self, code):
 """ Retrieve a language by a code. :param code: iso code (any of the three) or its culture code :return: a Language object """

        if any(x in code for x in ('_', '-')):
            cc = CultureCode.objects.get(code=code.replace('_', '-'))
            return cc.language

        elif len(code) == 2:
            return self.get(iso_639_1=code)

        elif len(code) == 3:
            return self.get(Q(iso_639_2T=code) |
                            Q(iso_639_2B=code) |
                            Q(iso_639_3=code))

        raise ValueError(
            'Code must be either 2, or 3 characters: "%s" is %s' % (code, len(code)))